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

前端 未结 26 2978
感动是毒
感动是毒 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:29

    You can specify it as text, but add pettern, that match numbers only:

    
    

    It works perfect and also on mobile ( tested on iOS 8 and Android ) pops out the number keyboard.

提交回复
热议问题