i have a group of 5 textfields, the user enters a quantity in them.
I need:
- if the user enters a quantity in any of the textboxes, the total for the entire group must be at least 5
- if the user doesn't enter any values in the textboxes, then the form will process as normal (the user does not have to enter any quantity in these fields.)
i have this so far:
var ham = document.receptionitems.qty1.value;
var cheese = document.receptionitems.qty2.value;
var
chicken = document.receptionitems.qty3.value;
var shrimp = document.receptionitems.qty4.value;
var egg = document.receptionitems.qty5.value;
var total = parseInt(ham) + parseInt(cheese) + parseInt(chicken) + parseInt(shrimp) + parseInt(egg);
window.alert(total)
if ((total!="") && (total<5))
{
window.alert("works!")
document.receptionitems.qty1.focus();
return false;
}
so the 2 problems i mentioned at the start were what was bugging me. when there is a blank textbox, the alert i get just says: NaN
If anyone can help, i'd greatly appreciate it!!
THANKS.