refiking Posted November 21, 2008 Share Posted November 21, 2008 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 More sharing options...
Psycho Posted November 21, 2008 Share Posted November 21, 2008 You have two different functions with the same name "validate_form". Each function needs a unique name. Link to comment https://forums.phpfreaks.com/topic/133686-2-forms-need-validation-dont-know-how/#findComment-695699 Share on other sites More sharing options...
refiking Posted November 21, 2008 Author Share Posted November 21, 2008 You have two different functions with the same name "validate_form". Each function needs a unique name. Link to comment https://forums.phpfreaks.com/topic/133686-2-forms-need-validation-dont-know-how/#findComment-695820 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.