Forum Moderators: open

Message Too Old, No Replies

JavaScript Clash

2 statements required for the onSubmit command

         

lazydays

2:18 pm on May 28, 2003 (gmt 0)



Hi there!

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%">&nbsp;</TD>
<TD WIDTH="61%"><INPUT NAME="requiredName" TYPE="text" COLS="20"></TD></TR>
<TR><TD ALIGN="right">Company Name</TD>
<TD>&nbsp;</TD>
<TD><INPUT NAME="requiredCompany" TYPE="text" MAXLENGTH="20"></TD></TR>
<TR><TD ALIGN="right" VALIGN="top">Enquiry</TD>
<TD>&nbsp;</TD>
<TD><textarea ROWS="3" NAME="requiredEnquiry" COLS="25"></TEXTAREA></TD></TR>
<TR><TD>&nbsp</TD>
<TD>&nbsp;</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]

korkus2000

2:22 pm on May 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld lazydays,

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?

lazydays

2:42 pm on May 28, 2003 (gmt 0)



I am sure I have made this work previously, only trouble is, I can't seem to find the files that I made at the time!

Time to go right back to the archives I think!

Thanks

korkus2000

3:04 pm on May 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would consider not using mailto. It is not supported very well and you will lose people who use web based email. Have a look at this thread:
[webmasterworld.com...]