Click to See Complete Forum and Search --> : Validate form, Submit, then a Thank You pg


David12846
01-01-2003, 11:29 PM
Hi Folks:

I'm kind of new to Javascript. So far I've stuck with cut'n'paste until I have more knowledge. Besides, I'm using a Webtv. I manage a High School Alumni web site. Users submit their mailing addresses in a form. That works okay. Formerly, I had an OnTimer function to send them to a "Thank You" page after the form was sent. It worked only some of the time, so I got rid of the OnTimer. I now have a validation script to verify they entered a Class Year, Name, Address, City, etcetera. The validation works using an OnClick function call. What I really want it to do is Validate the fields, then either: (1) Pop-up message to advise there are errors, or (2) if the validated fields are okay, Send the form AND THEN automatically go to a "Thank You" page.

Here's what I've tried...

1) OnClick function-name to validate on the Submit button and a URL redirect as a <FORM> option.

2) OnClick function-name to redirect on the Submit button and a validation script in the <FORM> option.

3) Added a "return" option to each script call in "1" and "2" above.

4) Did "1", "2", and "3" again using OnSubmit instead of OnClick.

I can get the form to validate and send if validation passes, but it doesn't go to a "Thank You" page. I can get it to go to the "Thank You " page, but it won't validate and send. Please, I want it to validate, and if it passes, send the form and then go to the "Thank You" page.

5sisters
01-02-2003, 04:22 AM
By the sounds of things you are misunderstanding how the thank you page thing works....

On most sites the thank you page is displayed after submitting due to formail

You might have too low a version of formmail in your cgi-bin

with my version (& most)
<input type="hidden" name="redirect" value="http://www.mysite.com/thanks.htm">
in your form is all you need...

No fancy javascript at all!!!

Try http://www.scriptarchive.com/ for a better version of formmail & then use the above....

Or you may find that just the above hidden field is enough if you didn't already know that that should work...

Charley :)

jeffmott
01-02-2003, 06:45 PM
5sisters
Try http://www.scriptarchive.com/ for a better version of formmail

Please do not recommend Matt's scripts. Even Matt no longer recommends his scripts.
Security Focus put MSA FormMail attacks third in their list of the Top Attacks for the 1st Quarter of 2002 (http://www.securityfocus.com/corporate/research/top10attacks_q1_2002.shtml).

David12846
01-02-2003, 10:57 PM
Here's part of my page. For clarity, I removed some non essential text, the Font tags, alignments, and a few input fields such as First and Maiden Names.

I may have been somewhat vague when I mentioned the various steps I tried. I mentioned them as "1)", "2)", "3)", and "4)". I tried each of those steps separately. I tried what was mentioned in "1)" first, then I tried "2)", etc. I did not try all of them at one time.

In advance, Thank you - David

<!-- BEGIN
function checkFields() {
missinginfo = "";
if (document.form.CYear.value == "") {
missinginfo += "\n - Class Year";
}
if (document.form.LName.value == "") {
missinginfo += "\n - Last Name";
}
if (document.form.Story.value == "") {
missinginfo += "\n - Your Story";
}
if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"You failed to correctly fill in your:\n" +
missinginfo + "\n_____________________________" +
"\nPlease re-enter and send again!";
alert(missinginfo);
return false;
}
else return true;
}
// End -->
</script>
<TABLE ALIGN="Center"><TR><TD>
<form name=form action= "mailto:myaddress@domain.net?no_signature=true &subject=HLCSAlumni Your Story"
method="post"
OnSubmit=location.href="SendThank.html";>
Class of What Year ?
<INPUT TYPE="text" MAXLENGTH="4" NAME="CYear" COLS="4">
<BR>Last
<INPUT TYPE="text" NAME="LName" COLS="30">
<BR><BR>Your Story
<TEXTAREA NAME="Story" COLS="50" ROWS="10"></TEXTAREA>
<BR><BR>
<input type=submit name="submit" value="SEND"
OnClick="return checkFields();">
</FORM></TD></TR></TABLE></BODY></HTML>

David12846
01-05-2003, 08:41 AM
Thanks for all the help. My page works now.

David (Eastern Upstate NY)

missp
07-09-2003, 10:36 PM
Originally posted by jeffmott
Please do not recommend Matt's scripts. Even Matt no longer recommends his scripts.
Security Focus put MSA FormMail attacks third in their list of the Top Attacks for the 1st Quarter of 2002 (http://www.securityfocus.com/corporate/research/top10attacks_q1_2002.shtml).

From Matt's page:

SECURITY UPDATE -- April 19, 2002 -- UPGRADE IMMEDIATELY
Any users who have versions of FormMail prior to v1.91, including the popular version 1.6, should upgrade immediately. v1.91 plugs several more spam-related security holes. The following fixes have also been implemented since v1.6: prevents unwanted access to environment variables and problem of receiving e-mail while using the redirect option.

Jeff Mott
07-10-2003, 06:21 AM
Matt Wright
While the free code found at my web site has not evolved much in recent years, the general programming practices and standards of CGI programs have.

...bad programming practices and bugs found in the existing Matt's Script Archive code.

The code you find at Matt's Script Archive is not representative of how even I would code these days.