Private Sub txtEmailID_Validated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtEmailID.Validated
If txtEmailID.Text.Trim() <> "" Then
Dim emailvl As Boolean = EmailValid(txtEmailID.Text.ToString.Trim())
If emailvl = False Then
MsgBox("Please, Enter Valid Email")
txtEmailID.Focus()
End If
End If
End Sub
Public Function EmailValid(ByVal email As String) As Boolean
' The regular expression rule
Dim Expression As New System.Text.RegularExpressions.Regex("\S+@\S+\.\S+")
' If the email matches the regular expression
If Expression.IsMatch(email) Then
' MessageBox.Show("The email address is valid.")
Return True
Else
' MessageBox.Show("The email address is NOT valid.")
Return False
End If
End Function
Friday, June 27, 2008
Subscribe to:
Post Comments (Atom)
3 comments:
Any assembly has to import for email validation??
yes,
assembly has to import for email validation also.
Patel
This is an excellent library for verifying email addresses:
http://www.kellermansoftware.com/p-37-net-email-validation.aspx
Post a Comment