When using type="number" on an input field, regex validation does not appear to work.
<input type="number" step="any" min="0" max="24" value="0">
The new broswer based validation using step, min, max works as expected. However this is not consistent accross browsers?
QUESTION
How to make a number field validate using regular expression?
I'm also interested in other factors that differentiate a number and text field if anyone has information.
NOTES
I have discovered that checking for an empty string causes validation to fire IF the conditions on the number field are not met.
element.validity.validto check if the input contains valid number. There is also apatternattribute in which you can set a regex to validate your input. Finally, you can prevent a user from typing something else than numbers by using keypress : stackoverflow.com/a/15649226/2806497