Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

IsValidEmail - Validate an email address

Total Hit ( 3596)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 



Click here to copy the following block
Function IsValidEmail(ByVal Value As String, Optional ByVal MaxLength As _
  Integer = 255, Optional ByVal IsRequired As Boolean = True) As Boolean
  If Value Is Nothing OrElse Value.Length = 0 Then
    ' rule out the null string case
    Return Not IsRequired
  ElseIf Value.Length > MaxLength Then
    ' rule out values that are longer than allowed
    Return False
  End If

  ' search invalid chars
  If Not System.Text.RegularExpressions.Regex.IsMatch(Value, _
    "^[-A-Za-z0-9_@.]+$") Then Return False

  ' search the @ char
  Dim i As Integer = Value.IndexOf("@"c)
  ' there must be at least three chars after the @
  If i <= 0 Or i >= Value.Length - 3 Then Return False
  ' ensure there is only one @ char
  If Value.IndexOf("@"c, i + 1) >= 0 Then Return False

  ' check that the domain portion contains at least one dot
  Dim j As Integer = Value.LastIndexOf("."c)
  ' it can't be before or immediately after the @ char
  If j < 0 Or j <= i + 1 Then Return False

  ' if we get here the address if validated
  Return True
End Function


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.