Below is the code for a function 'validEmail' that will check the syntax of an email. Note that the function will only check for the proper syntax it will not check to make sure if the email really exists. If the email is valid then it will return True otherwise it will return False.
<%
Function validEmail(strEmail)
Dim objRE, blnOK
validEmail = False
Set objRE = New RegExp
objRE.Pattern ="^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$"
objRE.IgnoreCase = true
blnOK = objRE.Test(strEmail)
If Not blnOK Then
Exit Function
End If
validEmail = True
End Function
%>
Using the function above here are 2 examples:
<% Response.write validEmail("test@testemail") %>
Output:
False
<% Response.write validEmail("test@testemail.com") %>
Output:
True
Get the best asp web hosting provider now and save 30%
Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.