I have a working code for entering valid minimum and maximum value in text box by using below code:
<input type="number" name="quantity" min="1" max="5">
But how about if I have multiple ranges allowed? For example: In my text box, numbers from 1 to 5 and 10 to 15 is allowed, so numbers from 6-9 and 16 & up is not allowed. How to do this using javascript/jquery or angularjs?
You can use the html5 pattern
attribute
<input type="text" name="quantity" pattern= "(1|2|3|4|5|10|11|12|13|14|15)" />
See here on the MDN website for further details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With