Hi
I hope someone can help me. I have a client side form validation script
which works perfectly in IE but clicking "Submit" in Mozilla does
nothing - the form won't submit.
Is there something I can use that will work for both browsers, or is
there something wrong with my code? I seem to think that the problem
lies with the "onclick" area of the form.
This is my code, such as it is...
<SCRIPT LANGUAGE="JavaS cript">
function ValidateEntries () {
if (MyForm.InputNa me.value == "") {
alert ("\nPlease enter your first name.")
return false;
}
if (MyForm.InputSu rname.value == "") {
alert ("\nPlease enter your Surname.")
return false;
}
if ((MyForm.InputE mail.value == "") ||
(MyForm.InputEm ail.value.index Of('@') == -1) ||
(MyForm.InputEm ail.value.index Of('.') == -1)) {
alert ("\nPlease enter your Email Address.")
return false;
}
if (MyForm.InputAd dress.value == "") {
alert ("\nPlease enter your Address.")
return false;
}
if (MyForm.InputPo stalcode.value == "") {
alert ("\nPlease enter your Postalcode.")
return false;
}
if (MyForm.InputTe lephoneNumber.v alue == "") {
alert ("\nPlease enter your Telephone Number.")
return false;
}
if (MyForm.InputCo mments.value == "") {
alert ("\nPlease type your Comments.")
return false;
}
else return document.MyForm .submit();
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled </title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1"></head>
<body bgcolor="#CCCCC C" leftmargin="5" topmargin="0">
<Form name="MyForm" action="sendmai l.asp" method="post">
<table width="534" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td valign="top"><f ont size="2" face="Arial, Helvetica,
sans-serif">Name
: </font></td>
<td valign="top"><i nput type="text" name="InputName "></td>
</tr>
<tr>
<td valign="top"><f ont size="2" face="Arial, Helvetica,
sans-serif">Surname
: </font></td>
<td valign="top"><i nput type="text" name="InputSurn ame"></td>
</tr>
<tr>
<td valign="top"><f ont size="2" face="Arial, Helvetica,
sans-serif">e-mail
Address: </font></td>
<td valign="top"><i nput type="text" name="InputEmai l"></td>
</tr>
<tr>
<td valign="top"><f ont size="2" face="Arial, Helvetica,
sans-serif">Physical
Address : </font></td>
<td valign="top"><t extarea name="InputAddr ess" rows="5"
cols="30"></textarea></td>
</tr>
<tr>
<td valign="top"><f ont size="2" face="Arial, Helvetica,
sans-serif">Postal
code : </font></td>
<td valign="top"><i nput type="text" name="InputPost alcode"></td>
</tr>
<tr>
<td valign="top"><f ont size="2" face="Arial, Helvetica,
sans-serif">Telephon e
Number : </font></td>
<td valign="top"><i nput type="text"
name="InputTele phoneNumber"></td>
</tr>
<tr>
<td valign="top"><f ont size="2" face="Arial, Helvetica,
sans-serif">Message
: </font></td>
<td valign="top"><t extarea name="InputComm ents" rows="5"
cols="30"></textarea></td>
</tr>
<tr>
<td colspan="2" valign="top"> <input type="button" value="Submit"
onclick="Valida teEntries()">
</td>
</tr>
</table>
</Form>
</body>
If anyone could help me, I would seriously reconsider dashing my
forehead against the desk
</thanks>
I hope someone can help me. I have a client side form validation script
which works perfectly in IE but clicking "Submit" in Mozilla does
nothing - the form won't submit.
Is there something I can use that will work for both browsers, or is
there something wrong with my code? I seem to think that the problem
lies with the "onclick" area of the form.
This is my code, such as it is...
<SCRIPT LANGUAGE="JavaS cript">
function ValidateEntries () {
if (MyForm.InputNa me.value == "") {
alert ("\nPlease enter your first name.")
return false;
}
if (MyForm.InputSu rname.value == "") {
alert ("\nPlease enter your Surname.")
return false;
}
if ((MyForm.InputE mail.value == "") ||
(MyForm.InputEm ail.value.index Of('@') == -1) ||
(MyForm.InputEm ail.value.index Of('.') == -1)) {
alert ("\nPlease enter your Email Address.")
return false;
}
if (MyForm.InputAd dress.value == "") {
alert ("\nPlease enter your Address.")
return false;
}
if (MyForm.InputPo stalcode.value == "") {
alert ("\nPlease enter your Postalcode.")
return false;
}
if (MyForm.InputTe lephoneNumber.v alue == "") {
alert ("\nPlease enter your Telephone Number.")
return false;
}
if (MyForm.InputCo mments.value == "") {
alert ("\nPlease type your Comments.")
return false;
}
else return document.MyForm .submit();
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled </title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1"></head>
<body bgcolor="#CCCCC C" leftmargin="5" topmargin="0">
<Form name="MyForm" action="sendmai l.asp" method="post">
<table width="534" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td valign="top"><f ont size="2" face="Arial, Helvetica,
sans-serif">Name
: </font></td>
<td valign="top"><i nput type="text" name="InputName "></td>
</tr>
<tr>
<td valign="top"><f ont size="2" face="Arial, Helvetica,
sans-serif">Surname
: </font></td>
<td valign="top"><i nput type="text" name="InputSurn ame"></td>
</tr>
<tr>
<td valign="top"><f ont size="2" face="Arial, Helvetica,
sans-serif">e-mail
Address: </font></td>
<td valign="top"><i nput type="text" name="InputEmai l"></td>
</tr>
<tr>
<td valign="top"><f ont size="2" face="Arial, Helvetica,
sans-serif">Physical
Address : </font></td>
<td valign="top"><t extarea name="InputAddr ess" rows="5"
cols="30"></textarea></td>
</tr>
<tr>
<td valign="top"><f ont size="2" face="Arial, Helvetica,
sans-serif">Postal
code : </font></td>
<td valign="top"><i nput type="text" name="InputPost alcode"></td>
</tr>
<tr>
<td valign="top"><f ont size="2" face="Arial, Helvetica,
sans-serif">Telephon e
Number : </font></td>
<td valign="top"><i nput type="text"
name="InputTele phoneNumber"></td>
</tr>
<tr>
<td valign="top"><f ont size="2" face="Arial, Helvetica,
sans-serif">Message
: </font></td>
<td valign="top"><t extarea name="InputComm ents" rows="5"
cols="30"></textarea></td>
</tr>
<tr>
<td colspan="2" valign="top"> <input type="button" value="Submit"
onclick="Valida teEntries()">
</td>
</tr>
</table>
</Form>
</body>
If anyone could help me, I would seriously reconsider dashing my
forehead against the desk
</thanks>
Comment