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.