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

E.mail validation

Status
Not open for further replies.

LaPluma

Programmer
Feb 3, 2002
139
DE
Hello

I have a validation script to check that a proper e.mail address has been added to a form, but can't seem to get it to work.

Here's the code and I would be grateful for any suggestions.

Cheers

LaPluma

<%
Dim emailAddress
emailAddress = Request(&quot;Email&quot;)
if emailAddress <> &quot;&quot; then
emailAddress = Cstr(Email)
if emailAddress <> &quot;&quot; then
blnValidEmail = RegExpTest(Email)
if blnValidEmail then
Response.Write(&quot;Valid email address&quot;)
else
Response.Write(&quot;Not a valid email address&quot;)
end if
end if

Function RegExpTest(sEmail)
RegExpTest = false
Dim regEx, retVal
Set regEx = New RegExp

' Create regular expression:
regEx.Pattern =&quot;^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$&quot;

' Set pattern:
regEx.IgnoreCase = true

' Set case sensitivity.
retVal = regEx.Test(sEmail)

' Execute the search test.
If not retVal Then
exit function
End If

RegExpTest = true
End Function
Else
%>

<%End If %>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top