We help IT Professionals succeed at work.
Get Started

Validation JS Error in FireFox Only

dcayce
dcayce asked
on
471 Views
Last Modified: 2013-12-07
I had this great, compact validation & submit script refined last week by leakim971 and it was working perfectly. I noticed a problem then, in FireFox. If I run this script as is, in FireFox, it executes perfectly. However, if I add just one more input field (for an email address, let's say) and add another 'if' statement to validate that field, to read like this:
            if (document.reg_form.email.value=="") {
                  themessage = themessage + " - E-Mail:\n";
            }
what happens is that FireFox throws up an error stating "Application Error - An error has occurred in the program". That's all it says. Doesn't process the form information.

I've attached the code below to show how it looks with the added 'if' statement for the email validation field. Has anyone any experience with this kind of FireFox issue and know a workaround?

Thanks.

Cayce
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans nom</title>
<SCRIPT LANGUAGE="JavaScript">
function verify() {
var themessage = "Please Check the Following Fields: \n";
		
if (document.reg_form.Name.value=="") {
themessage = themessage + " - Name:\n";
//Adding this next if statement causes a problem in FireFox
}if (document.reg_form.email.value=="") {
themessage = themessage + " - E-Mail:\n";
}
//alert if fields are empty and cancel form submit
if (themessage != "Please Check the Following Fields: \n") {
alert(themessage);
return false;
}
return true;
}
</script>
<script type="text/javascript">
<!--
	function frmSubmit() {
		document.reg_form.target = "_blank";
		document.reg_form.action = "FormOrder.pl"
		document.reg_form.submit();
		setTimeout('document.reg_form.target = "_self";window.location = "thank_you.shtml"',500);
	}
	
// -->
</script>
</head>
<body>
<form name="reg_form" id="reg_form" method="get" >

	<input name="Name" type="text" id="Name" />
	<input name="email" type="text" id="email" />

	<a href="#" onClick="if(verify()) frmSubmit(); else return false;"><img src="http://www.tarantin.com/images/orderForm_btn.gif" border="0"></a>
</form>
</body>
</html>

Open in new window

Comment
Watch Question
Fixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014
Commented:
This problem has been solved!
Unlock 1 Answer and 11 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE