-1
Good night. I have an input type number (so when I list my shopping cart can change the quantity)
<td>
<input
type="number"
style="width: 50px;"
id="<?php echo "p" . $a; ?>"
min="1"
max="<?php echo $max_produto; ?>"
value="<?php echo $values["item_quantity"]; ?>"
>
</td>
My problem is that even setting the min and max, if I change directly in the input without using the arrows I can put the value 0, or less than 0, that when I confirm the purchase it gets the amount put and should not happen. How can I solve this problem?
Only using the
required
andmin=1
here worked: http://jsbin.com/pocilifana. How you are submitting the form?– Woss
Do you intend to check only on client or server? The question is ambiguous.
– Mauro Alexandre
@Mauroalexandre on client
– Tiago Simoes
@Andersoncarloswoss tried and it didn’t work :(
– Tiago Simoes
@Tiagosimoes I believe that Valdeir’s response is the solution, if that’s the case, you’d better confirm, rather than continue with the comments.
– Mauro Alexandre
@Mauroalexandre already tested and did not work, and I do not know why my comment on the solution of the colleague was not sent :S
– Tiago Simoes
<input type="number" ..... oninput="if(this.value == 0) this.value = ''" />
– user60252
<input type="number" ...... oninput="this.value = Math.abs(this.value)"/>
– user60252