Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

JavaScript


  • Please log in to reply

#1
deke

deke

    Member

  • Member
  • PipPip
  • 13 posts
I have an error (in syntax, I think) somewhere in the following code. I cannot find what is wrong.

Here's what the code SHOULD do:

1. a web page user wants to join an association via an online membership form.
2. certain fields in the form are "required" fields.
3. on Submit, the function submit forms() is invoked to check various required fields for non-blanks.
4. the function checks the first group of fields for non-blanks and, if these fields are non-blank, checks to see if field, 'membershiptype' is not equal to "Retired ($25)." If true, the function continues with the checking for non-blanks for the rest of the fields on the form and then alerts a msg indicating the form is about to be submitted.
5. If any one field is blank, an alert is issued indicating so and focus is set back to the field with the blank entry.

I havethis whole validity-checkig process working until I added the check a 'membershiptype.' With that code added the function ALWAYS return true, even when I leave the first requires field blank.

So, it looks like something is wrong in my syntax or my if ...else clauses. Here's the code:
++++++++++++++++++++++++++++++
function submitForms() {
if ( iscardholderfirstname() && iscardholderlastname() && isEmail() && isPhone1() && isPhone2() && isPhone3() && isAddress1() && isCity() && isUsstate() && isZip() && isBMonth() && isBDay() && isBYear() && isMembershipType() && isNewOrRenewal() )
if ( document.addform.MembershipType.value != "Retired ($25)")

if ( isSchool() && isCounty() && isPosition() && isCardType() && isCardNumber1() && isCardNumber2() && isCardNumber3() && isCardNumber4() && isExpireMonth() && isExpireYear() )
else
if ( isNewOrRenewal() && isCardType() && isCardNumber1() && isCardNumber2() && isCardNumber3() && isCardNumber4() && isExpireMonth() && isExpireYear() )

}
if (confirm("\n Your application is now ready to be submitted for processing. \n\nClick OK to submit; Cancel to abort."))
{
alert("\nYour submission will now be sent.\n\n\n Thank you for supporting PSTA.");
return true;
}
else
{
alert("\n You have chosen to abort the submission.");
return false;
}
else

return false;
}
++++++++++++++++++++++++++++++++++++

Can someone point me to the problem?

Thanks very much for taking time to look into this for me.
  • 0

Advertisements







Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP