I have a form below and validation
html code
<form name="rt_form" id="rt_form" method="post" onSubmit="return validate();">
<input type="text" value="NAME" name="fname">
<input type="text" value="EMAIL" name="femail">
<input type="text" value="CONTACT NUMBER" name="fphone">
<textarea name="fMESSAGE" cols="44" rows="8" id="MESSAGE">
</form>
Javascript code
function validate() {
alert("you have clicked");
if (document.rt_form.fname.value.length < 1 || document.rt_form.fname.value == "NAME") {
alert("Enter Name");
return false;
}
else if (!/^\S+@\S+\.\w+$/.test(document.rt_form.femail.value)) {
alert("Not a valid e-mail address");
return false;
}
else if (!/^\d+$/.test(document.rt_form.fphone.value)) {
alert("Enter valid Number");
return false;
}
else if (document.rt_form.fMESSAGE.value.length < 1 || document.rt_form.fMESSAGE.value="MESSAGE") {
alert("Enter Message");
return false;
}
else {
return true;
}
}
When i run this code in chrome it works good and when opened in firefox the validation is not working…
even the alertbox is not showing when clicked in firefox.
Is there any thing to add compability or something.
you have error an error for message at if condition
document.rt_form.fMESSAGE.value="MESSAGE"change this to
document.rt_form.fMESSAGE.value=="MESSAGE"and this post should be closed