100
rated 0 times
[
104]
[
4]
/ answers: 1 / hits: 15164
/ 11 Years ago, mon, may 20, 2013, 12:00:00
I'm trying to check if ALL inputs (.productTextInput
) have a value of zero.
If they are all zero then execute an alert, but only if they are ALL zero.
I have been able to check the first and all individually, but not all together.
HTML
<div class=container>
<div class=listQuantity>
<input type=text class=productTextInput name=AddToCart_Amount value=0>
</div>
<div class=listQuantity>
<input type=text class=productTextInput name=AddToCart_Amount value=0>
</div>
<div class=listQuantity>
<input type=text class=productTextInput name=AddToCart_Amount value=0>
</div>
</div>
Script
$('.productTextInput').each(function() {
if ($(this).val() <= 1){
alert(Must choose at least one product);
} else {
// do something
}
});
More From » jquery