Email Validaton
Email Validaton
Rate Email Validaton
(2(2 Vote))
Dim iTemp As Integer
Select Case KeyAscii
Case 8 'ASCII value of Back Space =8
' Back space is allowed at any time
Exit Sub
Case Asc("@") ' @ is allowed only if there are some characters in the textbox
If TextBox.SelStart = 0 Then
KeyAscii = 0
ElseIf InStr(1, TextBox, "@") > 0 Then
KeyAscii = 0
End If
Exit Sub
Case Asc(".") ' . is allowed only after printing @
iTemp = InStr(1, TextBox, "@")
If (iTemp = 0) Or (iTemp >= TextBox.SelStart) Then
KeyAscii = 0
Exit Sub
ElseIf TextBox.SelStart = 0 Then
KeyAscii = 0
Exit Sub
ElseIf Mid(TextBox, TextBox.SelStart, 1) = "." Then
KeyAscii = 0
Exit Sub
End If
Exit Sub
Case Asc("_") ' _ is allowed only before printing @
iTemp = InStr(1, TextBox, "@")
If (iTemp > 0) And (iTemp < TextBox.SelStart) Then
KeyAscii = 0
End If
Exit Sub
End Select
If Not ((KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) Or (KeyAscii >= Asc("a") And KeyAscii <= Asc("z")) Or (KeyAscii >= Asc("A") And KeyAscii <= Asc("Z"))) Then
KeyAscii = 0
Exit Sub
End If
Email Validaton Comments
No comments yet — be the first to post one!
Post a Comment