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

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

    As with type="number", you specify a max instead of maxlength property, which is the maximum possible number possible. So with 4 digits, max should be 9999, 5 digits 99999 and so on.

    Also if you want to make sure it is a positive number, you could set min="0", ensuring positive numbers.

提交回复
热议问题