Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FORM validate, e-mail, and redirect 1

Status
Not open for further replies.

5656

Technical User
Jan 6, 2001
68
US
I posted this in the ASP forum and was told I should use JavaScript rather than ASP...
How could I accomplish the following:(that works in both IE and Netscape):

>> VALIDATE MY FORM fields (communicating to user which
fields are in error)
>> E-MAIL form results TO my e-mail adrress
>> REDIRECT the user to a CONFIRMATION / THANKYOU
page upon successful completion of the form.

Any information would be most appreciated...
Thanks !!
 
Sounds like that would be easier to do with a combination of the two.
Use JavaScript to validate the form contents on the client side.
Use ASP to format and send the email and redirect the user to the desired page. Mise Le Meas,

Mighty :)
 
I'm new to JavaScript and ASP...how would I go about using both the JavaScript and ASP to meet my needs ?

Thanks you !
 
Put this between your <head> and </head> tags
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--

function DataValidation()
{

if (document.NameofForm.NameofField1.value == &quot;&quot;) {

alert(&quot;You must enter a value for the NameofField1!&quot;);
return false;

}

if (document.NameofForm.NameofField2.value == &quot;&quot;) {

alert(&quot;You must enter a value for the NameofField2!&quot;);
return false;

}


return true;

}


// -->
</SCRIPT>


and then put this in your form tag
<FORM NAME=&quot;NameofForm&quot; ONSUBMIT=&quot;return DataValidation();&quot; action=&quot;emailProcess.asp&quot; method=&quot;post&quot;>


and then save this in a file called emailProcess.asp

<%
If Request.Form(&quot;submit&quot;)=&quot;Submit&quot; Then
body=&quot;***///// Contact Form \\\\\***&quot; & VbCrLf
body=body & &quot;NameofField1: &quot; & Request.Form(&quot;NameofField1&quot;) & VbCrLf
body=body & &quot;NameofField12: &quot; & Request.Form(&quot;NameofField12&quot;) & VbCrLf
Set ObjMail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
ObjMail.To = &quot;Put your email address here&quot;
ObjMail.From = &quot;Website&quot;
ObjMail.Subject = &quot;Contact Form&quot;
ObjMail.Body = body
ObjMail.Send
Set ObjMail = Nothing
response.Redirect &quot;index.asp?service=yes&quot;
response.End
End If
%>


I edited this in a hurry to fit your needs so there still might be a change or two to be made. Hope this helps.

Jewel
 
In the asp I forgot to change one thing.

the line

response.Redirect &quot;index.asp?service=yes&quot;

should be

response.Redirect&quot;ConfirmationPage.html&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top