Forum Moderators: open
I am new to JavaScript but have created a form that validates the fields, and then redirects the user to a new page.
However, only the validation code is working. Please can someone tell me what basic mistake I am making!
Code for required fields is in Head content.
<form method="post" action="mailto:example@example.com.com" onSubmit="return checkrequired(this)";window.setTimeout("location.href='thanks.htm'",1000) name="GeneralEnquiry"
enctype="text/plain">
<INPUT TYPE="hidden" NAME="GeneralEnquiry" VALUE="General
Enquiry">
<TABLE WIDTH="100%" BORDER="0">
<TR><TD WIDTH="37%" ALIGN="right">Contact Name</TD>
<TD WIDTH="2%"> </TD>
<TD WIDTH="61%"><INPUT NAME="requiredName" TYPE="text" COLS="20"></TD></TR>
<TR><TD ALIGN="right">Company Name</TD>
<TD> </TD>
<TD><INPUT NAME="requiredCompany" TYPE="text" MAXLENGTH="20"></TD></TR>
<TR><TD ALIGN="right" VALIGN="top">Enquiry</TD>
<TD> </TD>
<TD><textarea ROWS="3" NAME="requiredEnquiry" COLS="25"></TEXTAREA></TD></TR>
<TR><TD> </TD>
<TD> </TD>
<TD><input type="submit" name="SubmitButton" value="Submit"></TD></TR>
</TABLE>
</FORM>
[edited by: korkus2000 at 2:31 pm (utc) on May 28, 2003]
[edit reason] widgetized email [/edit]
This part is out side of the onSubmit event handler:
<form method="post" action="mailto:example@example.com" onSubmit="return checkrequired(this)";window.setTimeout("location.href='thanks.htm'",1000) name="GeneralEnquiry"
enctype="text/plain">
Your next problem is that you have double quotes in the setTimeout function. I have never tried to do a setTimeout redirect from the onSubmit field. Are you sure it works?
Time to go right back to the archives I think!
Thanks