I need that when entering quantity in an input it only lets me enter up to 8000 and that if I put 8500 for example it tells me that the maximum quantity is 8000.
<input type="text" id="breadth1" maxlength="8000" class="form-control big" placeholder="Ingrese ancho total">
I have this input but I don't know how to do it.
You have to change your
input
to one like this, the attributetype
must benumber
, and with the attributesmax
andmin
you give it the range you want:Now, if you want to validate it with
jquery
, you could do the following:You can use javascript to do the validation, in this case I used ternary operators which is nothing more than an if (?) else (:) to simplify the code a bit more.
You could do the following:
max
ofHTML5
forinput
typesnumber
.Example:
Example
jQuery
: