Jump to content

2 Forms Need Validation - Don't Know How


refiking

Recommended Posts

The first form validates perfectly.  The other one is ignored.  I'm sure it's just a syntax error, but I don't know what to do.  Here's the script:

<script type="text/javascript">
   function validate_required(field,alerttxt)
   {
   with (field)
   {
   if (value==null||value=="")
      {alert(alerttxt);return false;}
   else {return true}
   }
   }

   function validate_form(thisform)
   {
   with (thisform)
   {
   if (validate_required(email,"Email must be filled out!")==false)
      {email.focus();return false;}
   if (validate_required(first_name,"First Name must be filled out!")==false)
      {first_name.focus();return false;}
   if (validate_required(last_name,"Last Name must be filled out!")==false)
      {last_name.focus();return false;}
   if (validate_required(addy,"Address must be filled out!")==false)
      {addy.focus();return false;}
   if (validate_required(city,"City must be filled out!")==false)
      {city.focus();return false;}
   if (validate_required(state,"State must be filled out!")==false)
      {state.focus();return false;}
   if (validate_required(zip,"Zip Code must be filled out!")==false)
      {zip.focus();return false;}
   if (validate_required(years,"Number Of Years must be filled out!")==false)
      {years.focus();return false;}
   if (validate_required(mnth,"Number Of Months must be filled out!")==false)
      {mnth.focus();return false;}
   if (validate_required(day,"Day must be filled out!")==false)
      {day.focus();return false;}
   if (validate_required(month,"Month must be filled out!")==false)
      {month.focus();return false;}
   if (validate_required(year,"Year must be filled out!")==false)
      {year.focus();return false;}
   }
   }
    function validate_form(nextform)
   {
   with (nextform)
   {
   if (validate_required(bankname,"Bank Name must be filled out!")==false)
      {bankname.focus();return false;}
   if (validate_required(acct,"Account Number must be filled out!")==false)
      {acct.focus();return false;}
   if (validate_required(rout,"Routing Number must be filled out!")==false)
      {rout.focus();return false;}
   if (validate_required(naia,"Name on bank account must be filled out!")==false)
      {naia.focus();return false;}
   }
   }
   </script>

Under Form Action:

 

Form 1 is onsubmit="return validate_form(this)"  - Works Perfectly

Form 2 is onsubmit="return validate_form(next)" - Ignored

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.