email address validation

  • Thread starter Thread starter dave
  • Start date Start date
Validate it in what way... Give us some info so that we can answer your
question properly.
 
Hi :)
http://www.isi.edu/in-notes/rfc822.txt would be a good place to start.
Plus, without to much complexity, here's a quickly thrown together vb
routine that will get you part of the way there.

Public Function isValidEmail(inEmailAddress As String) As Boolean

If (Len(inEmailAddress) = 0) Then
MsgBox "Please enter your email address."
isValidEmail = False
Exit Function
End If
If (InStr(1, inEmailAddress, "@") = 0) Then
MsgBox "The '@' is missing from your e-mail address."
isValidEmail = False
Exit Function
End If
If (InStr(1, inEmailAddress, ".") = 0) Then
MsgBox "The '.' is missing from your e-mail address."
isValidEmail = False
Exit Function
End If

If (InStr(inEmailAddress, "@.") > 0) Then
MsgBox "There is nothing between '@' and '.'"
isValidEmail = False
Exit Function
End If

If ((InStr(inEmailAddress, ".")) = ((Len(inEmailAddress)))) Then
MsgBox "There has to be something after the '.'"
isValidEmail = False
Exit Function
End If

If ((Len(inEmailAddress)) < (InStr(inEmailAddress, ".") + 2)) Then
MsgBox "There should be two letters after the '.'"
isValidEmail = False
Exit Function
End If

If (InStr(1, inEmailAddress, "@") = 1) Then
MsgBox "You have to have something before the '@'"
isValidEmail = False
Exit Function
End If

isValidEmail = True
End Function

I hope this helps :)
wiz

Daniel formulated on Wednesday :
 
Back
Top