Forum Moderators: open
I have a problem and don't understand why. The else if structure works up until the last check where it doesn't. If I put the last check above the previous else...if everything works fine.
Can't figure out what is wrong :(
Here is my code:
function checkStepOne(){
doc = document.sellerReg;
var name = doc.sName;
var address = doc.sAddress;
var phone = doc.sTel;
var email = doc.sEmail;
var board = doc.forSaleBoard;
var price = doc.apq_packTwoPrice.value;
var payment = doc.methodPay;
if (name.value == ""){
window.alert("Form not completed properly\n\nPlease enter the seller's name");
name.focus();
}
else if (address.value == ""){
window.alert("Form not completed properly\n\nPlease enter the seller's address");
address.focus();
}
else if (phone.value == ""){
window.alert("Form not completed properly\n\nPlease enter the seller's phone number");
phone.focus();
}
else if (email.value == ""){
window.alert("Form not completed properly\n\nPlease enter the seller's email address");
email.focus();
}
else if (price == "none"){
if ((board[0].checked == false)&&(board[1].checked == false)){
window.alert("Form not completed properly\n\nPlease select if you require a \'For Sale\' board");
}
}
else if ((payment[0].checked == false)&&(payment[1].checked == false)){
window.alert("Form not completed properly\n\nPlease select your preferred method of payment");
}
}//end function
Thanks for your help
Leo
else if (price == "none" && board[0].checked == false && board[1].checked == false){
window.alert("Form not completed properly\n\nPlease select if you require a \'For Sale\' board");
}
else if ((payment[0].checked == false)&&(payment[1].checked == false)){
window.alert("Form not completed properly\n\nPlease select your preferred method of payment");
}
...otherwise it will never get down to the last
else if if price is "none"