Email validation serverside

前端 未结 1 1076
春和景丽
春和景丽 2021-01-15 00:38

I\'m trying to validate emails but my code is not allowing a few scenarios..

Code

pvm = \"bw.stack@domain.com\" does not work
pvm = \"user@gmail.com\         


        
1条回答
  •  别那么骄傲
    2021-01-15 00:55

    Here is a fairly good valiation for email addresses. Please note though that its hard to get a completely 'all-knowing' validation.

    ' Function IsValidEmail
    ' Method checks if a string value is a valid email adress
    ' @Param val:  String containing email adress.
    ' @RETURN: True / False
    Public function IsValidEmail(ByRef val)
        IsValidEmail = RegExTest(val,"^[_a-zA-Z0-9-""'\/]+(\.[_a-zA-Z0-9-""'\/]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$")
    end function
    

    _

    Public function RegexTest(str, pattern)
        dim m_objRegex 
    
        set m_objRegex = New RegExp
        m_objRegex.Pattern = pattern
        m_objRegex.Global = True
        RegExTest = m_objRegex.Test(str)
    
        set m_objRegex = nothing 
    End function
    

    0 讨论(0)
提交回复
热议问题