0

Hi,

I am using RegularExpressionValidator to validate EmailID where ValidateExpresion is::

\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

Actually i want to validate EmailID that can also contain spaces.

example::

< raman@gmail.com >,<raman@gmail.com>,< raman@gmail.com>
I want to validate all of the above Email IDs as Valid.

Please help me

Thanks in advance

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by woodsrr
0

\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)* \w+([-.]\w+)

try this

Edited by DearDhruv: n/a

0

I think you should split on comma and remove spaces, '<' and '>' to get a better validation.

Just a thought...

If CheckEmailList("< email@someplace.com >, < email2@someplace.com>") Then
              ' your code here for success
        End If

    Private Function CheckEmailList(ByVal sEmilList As String) As Boolean
        Dim bRet As Boolean = True
        Dim sList() As String = sEmilList.Split(",")
        Dim sEmail As String

        For Each sEmail In sList
            sEmail = sEmail.Replace("<", "").Replace(">", "").Replace(" ","")
            If isValidEmail(sEmail) = False Then bRet = False
        Next

        Return bRet
    End Function

    Public Function isValidEmail(ByVal EmailAddress As String) As Boolean

        Dim strRegex As String = "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
        Dim re As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex(strRegex)
        If re.IsMatch(EmailAddress) Then
            Return True
        Else
            Return False
        End If
    End Function
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.