Limit number of characters in input type number

后端 未结 13 1694
逝去的感伤
逝去的感伤 2020-12-18 08:08

Im trying to limit to X number the characters in a input (type of number). ive tried a lot of options and none seems to work. I dont want to use the option tel as it needs t

13条回答
  •  抹茶落季
    2020-12-18 08:35

    The HTML5 number type input has min and max attributes.

    If you wanted to limit the number of characters to 1 you could set a min of 0 and a max of 9.

    You can also set the step attribute, which is 1 by default, but would come in use if you wanted the ability to select decimals or other rounded numbers.

    
    

    Here's the full demo

提交回复
热议问题