4
I have a field called Quantidade
that the quantity of products for sale should be inserted. My form has a data request that returns the value and quantity of products in stock, this field Quantidade
returns that amount of stock of products because of the id="quantidade"
, then you already receive a value.
Only that the field Quantidade
I wish I had a minimum and maximum limit for the inserted quantity using min
and max
within that <input>
, placing a PHP code inside the max
to set the maximum amount entered (the min
can be zero).
Example: If the field Quantidade
receives a value of 30 products because of data request, this field must allow an insertion of at least 0
up to the maximum 30
, leaving the field more intuitive.
JS code that requests the value in the field Quantidade
var retornoJson = JSON.parse(ajax.responseText);
document.querySelector("#quantidade").value = retornoJson[0].quantidade;
HTML code:
<p> Quantidade: <input type="number" name="quantidade" id="quantidade" required=""> </p>
There is, in fact, the type
type="int"
of<input>
in HTML?– Woss
Yes, that piece of code
<p> Quantidade </p>
that I posted, wanted it to be more intuitive in the amount it gets to set the maximum amount entered allowed.– user219364
type="int"´´´ o
<input>já possui, mas o usuário ele não sabe o valor mínimo é máximo para digitar nesse
<input>```, only returns the stock amount of a data request (eg: 30) wanted to prevent values above the allowed.– user219364
agree with o@Woss, do not know type=int, would be a type=number ai certo? https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
– Ricardo Pontual
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes The point is that
int
is not a valid type for the<input>
; for numerical values should be usednumber
.– Woss
There is no such type="int" no, we have 21 types and none of them is int. It has the type number, but who accepts max and min is the type range
– Franklin Barreto