PDA

View Full Version : document.form.submit can't work!


charon
10-04-2002, 09:23 AM
mai i know what is the possible problem cause my document.form.submit() can't give any response:
below is my code, I never face this problem before

<Script Language = "javascript">

function validateT()
{
if (document.formreg.name.value == "")
{
alert("Please fill in your name.");
document.formreg.name.focus();
}
else if (document.formreg.title.value == "")
{
alert("Please fill in the title.");
document.formreg.title.focus();
}
else if (document.formreg.address.value == "")
{
alert("Please fill in your address.");
document.formreg.address.focus();
}
else if ((document.formreg.telno.value != "") & (isNaN(document.formreg.telno.value) == true))
{
alert("Invalid contact number. Example:0123333888.");
document.formreg.telno.focus();
}
else if ((document.formreg.faxno.value != "") & (isNaN(document.formreg.faxno.value) == true))
{
alert("Invalid fax number. Example:031111888.");
document.formreg.telno.focus();
}
else
{

document.formreg.submit();
}
}
</Script>

ShriekForth
10-04-2002, 03:26 PM
Is there a problem with the form(name)? or another script on the page? when I use that code with this form


<form name="formreg" action="mirror.php" method="post">
<input type="text" name="name" value="absT"><br>
<input type="text" name="title" value="titleT"><br>
<input type="text" name="address" value="addressT"><br>
<input type="text" name="telno" value="123"><br>
<input type="text" name="faxno" value="123"><br>
</form>
<br>
<a href="javascript:validateT();">Validate</a>


it works just fine. Are you not seeing the error messages/alerts, or is it just not submitting? If there are more scripts on the page, and one errors some browsers might not run the rest of them.

ShriekForth

Roy Sinclair
10-04-2002, 03:28 PM
The script itself looks fine except for the fact that when the fax number input is rejected you're moving the focus to the telephone number. Have you verified that all the error messages are working? How are you calling this function?

charon
10-07-2002, 07:42 AM
thanks for all the reply, I have already settle, I also don't know what is the error, I just cut and paste the previous coding, and it works fine!!