It seems that neither of the "maxlength", "min" or "max" HTML attributes have the desired effect on iPhone for the following markup:
<input type="number" maxlength="2" min="0" max="99"/>
Instead of limiting the number of digits or the value of the number entered, the number is just left as it was typed in on iPhone 4. This markup works on most other phones we tested.
What gives?
Any workarounds?
If it is important to the solution, we use jQuery mobile.
Thanks!
Another option with jQuery, but onkeypress event... ;)
you can use this code:
and js code:
This is Tripex answer optimized for allowing delete key, works when typing and on paste.
According to MDN,
maxlength
is not used fornumber
s. Have you tried just:OR