Hello There,

I have a code for validation in a form in Html.
The javascript works perfectly in IE, but doesnt work in firefox.

The code is as follows:

<script type="text/javascript">
function Validate_contact()
      {
	  	var status;
        var err='';
		
		if(document.getElementById('EFirstname').value == '')
        {
             err+='Please Enter Your First Name';
             err+='\n';
             status = false;
        }
        else
        {
             err+= '';
             status = true;
        }
        
        if(document.getElementById('ELastname').value == '')
        {
             err +=  'Please Enter Your Last Name';
             err+='\n';
             status = false;
        }
         else
        {
             err+= '';
             status = true;
        }
        
        if(document.getElementById('EEMail').value == '')
        {
             err +=  'Please Enter Your Email Address';
             err+='\n';
             status = false;
        }
         else
        {
             err+= '';
             status = true;
        }

		var chks1 = document.getElementsByName('BHK[]');
		var hasChecked = false;
		for (var i = 0; i < chks1.length; i++)
		{		
			if (chks1[i].checked)
			{
				hasChecked = true;
				break;
			}
		}
		if (hasChecked == false)
		{
			err+='Please select at least Flat Type Option.';
			 err+='\n';
             status = false;
			
		}
		
		var chks = document.getElementsByName('Area[]');
		var hasChecked = false;
		for (var i = 0; i < chks.length; i++)
		{		
			if (chks[i].checked)
			{
				hasChecked = true;
				break;
			}
		}
		if (hasChecked == false)
		{
			err+='Please select at least one Area Option.';
			 err+='\n';
             status = false;
			
		}

	
	if(document.getElementById('Query').value == '')
        {
             err +=  'Please Enter your Message';
            
             status = false;
        }
         else
        {
             err+= '';
             status = true;
        }
        
        if(status==true)
        {
            return true;
        }
        else
        {
            alert(err);
            return false;
        }
			
		
     }
	 
</script>

Can anyone help.

Try changing the variable name status to something else. I think it is an old Javascript reserved word. But I am not sure whether that is the problem..

Member Avatar for stbuchok

Status is in the list of predefined names of implementation-dependent JavaScript.

http://www.kourbatov.com/faq/reserved.htm

If that is not the issue, can you provide us with an error message?

I will try and provide you with the error message. Actually when I have form in HTMl that gets posted to asp form which sends the email.
The html when opens up in Firefox shows no error. When one clicks on submit, the asp file opens up and shows an error but also sends the email.
Will post the error message in some time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.