1
How do I limit the value in my input? I tried to use it didn’t work use min="1" and max="3"
function process(quant){
var value = parseInt(document.getElementById("quant").value);
value+=quant;
if(value < 1){
document.getElementById("quant").value = 1;
}else{
document.getElementById("quant").value = value;
}
}
<div data-app="product.quantity" id="quantidade">
<span id="span_erro_carrinho" class="blocoAlerta" style="display:none;">Selecione uma opção para variação do produto</span>
<label>Quantidade:</label>
<input type="button" id="plus" value='-' onclick="process(-1)" />
<input id="quant" name="quant" class="text" min="1" max="3" size="1" type="text" value="1" maxlength="5" oninput="checa(this)" />
<input type="button" id="minus" value='+' min="1" max="3" onclick="process(1)">
</div>
To use min and max your field has to be like
type="number"
– ricardogobbo
Yes, this works if I type in the field, but if I use arrows to increase and decrease the value it does not limit even if use type="number"
– Hugo Rutemberg
It still doesn’t solve. see how my code https://answall.com/questions/451755/limitr-valor-do-input-com-javascript?noredirect=1#comment864086_451755
– Hugo Rutemberg