This code validates email address. Use the ValidateEmail() function.
This code validates email address. Use the ValidateEmail() function.
Rate This code validates email address. Use the ValidateEmail() function.
(1(1 Vote))
Dim j As Integer
If txtEmalAd.Text = "" Then GoTo ByPass1 'allow zero length
For j = 1 To Len(n)
If Mid(n, j, 1) = "@" Then 'check if address has @ sign
If Mid(n, j + 1, 1) = "." Then 'if @ sign is followed by period(.)
ValidateEmail = False
Exit For
End If
If j = 1 Then
ValidateEmail = False
Else
If ValidateExt(j, n) = True Then 'validate extention
ByPass1:
ValidateEmail = True
Else
ValidateEmail = False
End If
End If
Exit For
Else
ValidateEmail = False
End If
Next j
End Function
Function ValidateExt(Start As Integer, n As String) As Boolean
Dim j As Integer
Dim ext As String
Dim depot As String
For j = Start To Len(n)
depot = Mid(n, j, 1)
If depot = "." Then
ext = depot
ext = ext + Mid(n, j + 1, Len(n) - j)
If ext = ".com" Or _
ext = ".org" Or _
ext = ".net" Or _
ext = ".com.ph" Then
ValidateExt = True
Else
ValidateExt = False
End If
Exit For
End If
Next j
End Function
This code validates email address. Use the ValidateEmail() function. Comments
No comments yet — be the first to post one!
Post a Comment