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
https://forums.phpfreaks.com/topic/133686-2-forms-need-validation-dont-know-how/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.