Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Min and Max value for textbox

Tags:

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?

like image 854
Hsueh Avatar asked Mar 19 '16 07:03

Hsueh


1 Answers

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.

like image 112
Paul Fitzgerald Avatar answered Nov 15 '22 05:11

Paul Fitzgerald