VB.NET - Email Validation Function
Simple regular expression I found and have used succesfully to validate emails submitted to my website.
VB Code:
Imports System.Text.RegularExpressions
Function EmailAddressCheck(ByVal emailAddress As String) As Boolean
Dim pattern As String = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
Dim emailAddressMatch As Match = Regex.Match(emailAddress, pattern)
If emailAddressMatch.Success Then
EmailAddressCheck = True
Else
EmailAddressCheck = False
End If
End Function
Re: VB.NET - Email Validation Function
Quote:
Originally Posted by scuzymoto
Simple regular expression I found and have used succesfully to validate emails submitted to my website.
VB Code:
Imports System.Text.RegularExpressions
Function EmailAddressCheck(ByVal emailAddress As String) As Boolean
Dim pattern As String = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
Dim emailAddressMatch As Match = Regex.Match(emailAddress, pattern)
If emailAddressMatch.Success Then
EmailAddressCheck = True
Else
EmailAddressCheck = False
End If
End Function
Sorry Scuzymoto,
I am still an amatuer at regular expression.
Can you explain the use of ""^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ?
BlackCat
Re: VB.NET - Email Validation Function
bringing it back from the dead, my first post even too.
I am still an amatuer at regular expression.
Can you explain the use of ""^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$" ?
BlackCat and biggreen96
Re: VB.NET - Email Validation Function
An excellent website to describe all you could ever want to know...
http://www.regular-expressions.info/tutorialcnt.html
Re: VB.NET - Email Validation Function
Checkout this....
Some Simple Mothod.......
Dim Expression As New System.Text.RegularExpressions.Regex("\S+@\S+\.\S+")
If Expression.IsMatch(txtEMail.Text) Then
MsgBox("The email address is valid.")
Else
MsgBox("The email address is NOT valid.", MsgBoxStyle.Critical, "Invalid Mail ID")
Exit Sub
End If
Re: VB.NET - Email Validation Function
This seems to reject underscores _ in the email address, as in:
[email protected]
-Jay:confused:
Re: VB.NET - Email Validation Function
Re: VB.NET - Email Validation Function
Imports System.Text.RegularExpressions
Function EmailAddressCheck(ByVal emailAddress As String) As Boolean
Dim pattern As String = "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"
Dim emailAddressMatch As Match = Regex.Match(emailAddress, pattern)
If emailAddressMatch.Success Then
EmailAddressCheck = True
Else
EmailAddressCheck = False
End If
End Function
i want this code invb6.0 help me
Re: VB.NET - Email Validation Function
Quote:
Originally Posted by
satheeshs
i want this code invb6.0 help me
Check the VB6 code bank for the equalivant code.