/ Published in: ASP
URL: http://reusablecode.blogspot.com/2008/08/isvalidemail.html
Refer to the linked blog post for a broken-down explanation of the different components of the pattern.
Expand |
Embed | Plain Text
<% ' Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved. ' ' This work is licensed under the Creative Commons Attribution License. To view ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California ' 94305, USA. ' Validate an e-mail address. ' Supports quoted local part as well as IP address for the domain part. function isValidEmail(email) dim regEx dim result set regEx = new RegExp with regEx .IgnoreCase = True .Global = True .Pattern = "^[^@]{1,64}@[^@]{1,255}$" end with result = false ' Test length. if regEx.Test(email) then regEx.Pattern = "^((([\w\+\-]+)(\.[\w\+\-]+)*)|(\"[^(\\|\")]{0,62}\"))@(([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9]{2,})|\[?([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})(\.([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})){3}\]?)$" ' Test syntax. if regEx.Test(email) then result = true end if end if isValidEmail = result set regEx = nothing end function %>
You need to login to post a comment.
