How can I limit possible inputs in a HTML5 “number” element?

前端 未结 26 2850
感动是毒
感动是毒 2020-11-22 05:12

For element, maxlength is not working. How can I restrict the maxlength for that number element?

26条回答
  •  死守一世寂寞
    2020-11-22 05:26

    As stated by others, min/max is not the same as maxlength because people could still enter a float that would be larger than the maximum string length that you intended. To truly emulate the maxlength attribute, you can do something like this in a pinch (this is equivalent to maxlength="16"):

    
    

提交回复
热议问题