check verify email address and validation

While developing new site i had to add email verification function in vb.net, here is a handy function written in VB.NET to verify if email address is valid email address. This function does not verify if email address exists but simply checks if the string entered by end user is a valid email address.

It can check most common domain TLD's (com, net, org etc) you can also add your own if you like. It also allow hyphen ( - ), under score ( _ ) and a period ( . ) in the username part of the email address.

 

Public Shared Function Is_Valid_Email(ByVal Email_Address As String) As Boolean 

	Dim reg_pattern As String = "^[-a-zA-Z0-9][-_.a-zA-Z0-9]*@[-.a-zA-Z0-9]+(\.[-.a-zA-Z0-9]+)*\." & _ 
	"(com|net|org|biz|ru|jobs|edu|me|ws|info|gov|int|mil|us|co.uk|cn|.pk|.in|name|museum|coop|aero|pro|tv|[a-zA-Z]{2})$"
 	
	Dim reg As New Text.RegularExpressions.Regex(reg_pattern, RegexOptions.IgnorePatternWhitespace)

        	If String.IsNullOrEmpty(Email_Address) Then
         		Return False
        	Else
            	Return reg.IsMatch(Email_Address)
        End If
End Function
 

 

 

 




Add Comments

Name: *
Email: *
URL:
Comments: *