We Recommend

ASP.NET 3.5 Unleashed ASP.NET 3.5 Unleashed
ASP.NET 3.5 Unleashed is the most comprehensive book available on the Microsoft ASP.NET 3.5 Framework, covering all aspects of the ASP.NET 3.5 Framework--no matter how advanced.


Posted By

elightbo on 12/07/07


Tagged

form validation ASP


Versions (?)


Simple ASP form validation


Published in: ASP 


Needs work to check for hidden fields, and those that aren't required

  1. dim strError, msg
  2.  
  3. for i=1 to request.form.count
  4. if request.form(i) <> "" then
  5. msg=msg & request.form.key(i) & ": " & request.form(i) & vbcrlf
  6. else
  7. strError = strError & request.form.key(i) & ": " & "please complete this field<br>"
  8. end if
  9. next
  10.  
  11. if strError <> "" then
  12. 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>")
  13. else
  14. Set Mail = CreateObject("CDONTS.NewMail")
  15. with Mail
  16. .From = request.Form("email")
  17. .To = "neal.grosskopf@alliancels.com"
  18. .Subject = "Training IPSO OPL"
  19. .Body = msg
  20. .Send
  21. end with
  22. Set Mail = Nothing
  23. response.Write("<p>" & request.Form("name") & ", thank you for registering!</p>")
  24. 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>")
  25. end if

Report this snippet 

You need to login to post a comment.