Forum Moderators: open

Message Too Old, No Replies

else if statements

         

CodeMama

2:52 pm on Feb 24, 2009 (gmt 0)

10+ Year Member



Hi I am doing some form validation and need help with an else if statement
if the user has the account number great but if no account number they must have the address...
I thought I could do it something like this:
//Account Number or Address Section
if (WorkOrderNew.AccountNum.value === "") {
alert("You must enter a Account Number Name");
WorkOrderNew.AccountNum.focus();

else if (WorkOrderNew.Address.value === "") {
alert("With no Acct. Number you must enter the Address");
WorkOrderNew.Address.focus();
else if (WorkOrderNew.City.value === ""){
alert("You must enter the City");
WorkOrderNew.City.focus();

return false;
}
but it doesn't work..

Fotiman

4:11 pm on Feb 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld! You are missing your closing } on all your if statements. Try this:

//Account Number or Address Section
if (WorkOrderNew.AccountNum.value === "") {
alert("You must enter a Account Number Name");
WorkOrderNew.AccountNum.focus();
}
else if (WorkOrderNew.Address.value === "") {
alert("With no Acct. Number you must enter the Address");
WorkOrderNew.Address.focus();
}
else if (WorkOrderNew.City.value === ""){
alert("You must enter the City");
WorkOrderNew.City.focus();
}
return false;