How can I validate an email address using VBscript? [Print this FAQ]
Answer:
Thanks to Anders Rask for porting the validation code to VBscript! Using regular expressions, you can validate an email address using the following code:
<% Dim emailAddress emailAddress = Request("emailAddress") if emailAddress <> "" then emailAddress = Cstr(emailAddress) if emailAddress <> "" then blnValidEmail = RegExpTest(emailAddress) if blnValidEmail then Response.Write("Valid email address") else Response.Write("Not a valid email address") end if end if
Function RegExpTest(sEmail) RegExpTest = false Dim regEx, retVal Set regEx = New RegExp
FAQ posted by shedao at
10/8/2000 2:07:02 PM to the
Email category.
This FAQ has been viewed 115,252 times.
Do you have a FAQ you'd like to suggest?
Suggestions? Comments? If so, send it in!
Also, if you'd like to be a FAQ Admin (creating/editing FAQs),
let me know! If you are looking for other FAQs, be
sure to check out the 4Guys
FAQ and Commonly Asked Messageboard Questions!