Results 1 to 2 of 2

Thread: Class for Validating Email Address

  1. #1
    Join Date
    Nov 2004
    Posts
    41
    Rep Power
    0

    Post Class for Validating Email [VB.NET]

    Code:
    Imports System.Text.RegularExpressions
    Public MustInherit Class EmailValidate 
     Protected mvar_EmailAddress As String
        Protected mValidationExpression As New Regex("^([a-zA-Z0-9_\-])([a-zA-Z0-9_\-\.]*)@(\[((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}|((([a-zA-Z0-9\-]+)\.)+))([a-zA-Z]{2,}|(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\])$")
    
        Private Function IsValid(ByVal v As String) As Boolean
    
            If Not mValidationExpression Is Nothing Then
                Return mValidationExpression.IsMatch(v)
            Else
                Return True
            End If
        End Function
    
    
        Public Property Email() As String
            Get
                Return Me.mvar_EmailAddress
            End Get
            Set(ByVal  value As String)
                If  value.Length <> 0 Then 'If any character gets entered proceed
                    If Me.IsValid(value) = False Then
                        Throw New Exception("Invalid Email Address format")
    
                    Else
                        Me.mvar_EmailAddress = value
    
                    End If
                Else
                    Me.mvar_EmailAddress = ""
                End If
            End Set
        End Property
    
     End Class
    Last edited by Bredz; Feb 11, 2005 at 12:58 PM.

  2. #2
    Join Date
    Jul 2004
    Posts
    264
    Rep Power
    0

    Default Re: Class for Validating Email Address

    yow thet regular expression look dutty my yute .... it actually work

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •