Simple ASP form validation

dim strError, msg

for i=1 to request.form.count
if request.form(i) <> "" then
msg=msg & request.form.key(i) & ": " & request.form(i) & vbcrlf
else
strError = strError & request.form.key(i) & ": " & "please complete this field<br>"
end if
next

if strError <> "" then
response.Write("<p><b>The Following Fields Are Required</b></p>" & strError & "<p><a href='javascript:history.back()'>&lt;&lt; Please Go Back</a></p>")
else
Set Mail = CreateObject("CDONTS.NewMail")
with Mail
.From = request.Form("email")
.To = "neal.grosskopf@alliancels.com"
.Subject = "Training IPSO OPL"
.Body = msg
.Send
end with
Set Mail = Nothing
response.Write("<p>" & request.Form("name") & ", thank you for registering!</p>")
response.Write("<p>You will be contacted by a Company Representative to confirm your reservation and provide you with more details regarding the seminar.</p>")
end if

source

Leave a Reply