Jump to content

ASP Form Validation not working

Recommended Posts

Hi, I'm trying to add ASP validation to the form on this page here.Here's the code that I created:

<%If Request("POSTBACK") = "YES" Then	oops = ""		name = Trim(Request("name"))	Set nmre = New RegExp	nmre.Pattern = "^[a-zA-Z\'\-]{3,99}$"	If name = "Your Name" OR Not nmre.Test( Replace(name," ","") ) Then		oops = oops & "<li>Please enter your name</li>"	End If	Set emre = New RegExp	emre.Pattern = "^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$"	emre.IgnoreCase = True	If Not emre.Test( Request("email") ) Then		oops = oops & "<li>Please enter a valid email address</li>"	End If		If oops = "" Then		Server.Transfer "/ask-michael/#thankyou"	End If	Response.Write "Please correct the following errors and submit the form again:<ul>" & oops & "</ul>"End If%><form method="post" name="askmichael" onSubmit="return checkrefervalues();"><input name="POSTBACK" type="hidden" value="YES">

When I hit submit on the form (with all valid fields), I get this error: "Please correct the following errors and submit the form again:," with nothing listed. Am I close to getting this validation to work?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...