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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDONTS Field Validation

Status
Not open for further replies.

Boysie

Technical User
Nov 3, 2001
4
GB
I am using -

<%

email = request.form(&quot;email&quot;)

Dim objMail
Set objMail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
objMail.From = email
objMail.Subject = &quot;Newsletter Sign Up&quot;
objMail.To = &quot;OurEmail&quot;

body = &quot;Name&quot; & vbcrlf & request.form(&quot;name&quot;) & vbcrlf & vbcrlf
body = body & &quot;Email&quot; & vbcrlf & request.form(&quot;email&quot;) & vbcrlf & vbcrlf

objMail.Body = body
objMail.Send

Set objMail = nothing

%>

which works fine. However I wish to add some evaluation of the two fields, i.e. if one or both is empty and/or the email address field does not contain a valid email address then a pop-up informs the user. They then click a back button to try again.

Thanks

Pete Boys
 
Why not just put somthing like:

<%

email = Trim(request.form(&quot;email&quot;))
If email = &quot;&quot; Then
Response.write(&quot;You have not entered a valid email address.<BR>&quot;)
Response.write(&quot;Please go back and try again.<BR>&quot;)
Response.write(&quot;<A HREF=&quot;JAVASCRIPT:history.go(-1)&quot;><< Back</A><BR>&quot;)
Response.End
End If

...
%>

You can even check for a valid email address using somthing like this:

<%

email = Request.Form(&quot;email&quot;)

If instr(email,&quot;@&quot;)=0 or instr(email,&quot;.&quot;)=0 Then
Response.write(&quot;Invalid Email!&quot;)
Response.End
End IF

...
%>

Hope this is what you're lookin for. -Ovatvvon :-Q
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top