I wanted a simple way to restrict the number of allowing digits in my number input. You must change your input’s type to ‘text’ and add a pattern

<input type="text" pattern="\d*" maxlength="2">

This is much simpler than using a JS library and is supported IE 10+ and on mobile as well.

Related External Links: