E-M@il Validation.

Author Message
Jori

  • Total Posts : 5
  • Scores: 0
  • Reward points : 0
  • Joined: 11/25/2009
  • Status: offline
E-M@il Validation. Monday, December 21, 2009 4:51 AM (permalink)
0
Here is a E-M@il Validation script. I'm sorry that there is no comment, i'm from the Netherlands and my english isn't that good.
 
Please comment :-)
 
Here is the code:
 
 
 
'Sorry that there is no comment. This validator is translated from Ducht to English.
'My English isn't that good, so i'm sorry if there are spelling mistakes :-)
Titel = "Email Validator © Jori Koolstra"
EmailValidate
Sub EmailValidate
Do Until EmailOK = True
Email = InputBox ("Please enter your E-M@ils adress.",Titel,"Enter your E-M@il adress here.")
Trim(Email)
Grote = Len(Email)
posAap=InStr(Email,"@")
'List of valid characters.
ValChar1=InStr(Email,"!")
ValChar2=InStr(Email,"#")
ValChar3=InStr(Email,"$")
ValChar4=InStr(Email,"%")
ValChar5=InStr(Email,"€")
ValChar6=InStr(Email,"^")
ValChar7=InStr(Email,"&")
ValChar8=InStr(Email,chr(34))
ValChar9=InStr(Email,"*")
ValChar10=InStr(Email,"=")
ValChar11=InStr(Email,"<")
ValChar12=InStr(Email,">")
ValChar13=InStr(Email,"{")
ValChar14=InStr(Email,"}")
ValChar15=InStr(Email,"|")
ValChar16=InStr(Email,"`")
ValChar17=InStr(Email,"~")
ValChar18=InStr(Email,"©")
ValChar19=InStr(Email,"®")
ValChar20=InStr(Email,"¶")
ValChar21=InStr(Email,"ยด")
If (ValChar1 => 1) Or (ValChar2 => 1) Or (ValChar3 => 1) Or (ValChar4 => 1) Or (ValChar5 => 1) Or (ValChar6 => 1) Or (ValChar7 => 1) Or (ValChar8 => 1) Or (ValChar9 => 1) Or (ValChar10 => 1) Or (ValChar11 => 1) Or (ValChar12 => 1) Or (ValChar13 => 1) Or (ValChar14 => 1) Or (ValChar15 => 1) Or (ValChar16 => 1) Or (ValChar17 => 1) Or (ValChar18 => 1) Or (ValChar19 => 1) Or (ValChar20 => 1) Or (ValChar21 => 1) Then
MsgBox "*" & Email & "* is a valid E-M@il adress!",16 + 4096,Titel + " - Error"
EmailValidate
End If
If ((posAap = 1) = True) Then
MsgBox "*" & Email & "* is a valid E-M@il adress!",16 + 4096,Titel + " - Error"
EmailValidate
End If
If Grote = 0 Then
MsgBox "You need to enter someting!",16 + 4096,titel + " Error"
EmailValidate
End If
If ((posAap = 1) = True) Then
MsgBox "*" & Email & "* is a valid E-M@il adress!",16 + 4096,Titel + " - Error"
EmailValidate
End If
posPunt=InStr(Email,".")
If posPunt = 0 Then
MsgBox "*" & Email & "* is a valid E-M@il adress!",16 + 4096,Titel + " - Error"
EmailValidate
End If
NewStr = Mid(Email,posAap,Grote)
posPuntNaAap = InStr(NewStr,".")
If posPuntNaAap = 0 Then
MsgBox "*" & Email & "* is a valid E-M@il adress!",16 + 4096,Titel + " - Error"
EmailValidate
End If
posAap2 = InStr(NewStr,"@")
NewStr2 = Mid(NewStr,posAap2,posPuntNaAap)
NewStr2Length = Len(NewStr2)
If NewStr2Length =< 2 Then
MsgBox "*" & Email & "* is a valid E-M@il adress!",16 + 4096,Titel + " - Error"
EmailValidate
End If
HulpLen = Len(NewStr)
NewStr3 = Mid(NewStr,posPuntNaAap,HulpLen)
If (InStr(NewStr3,"nl") = 0) And (InStr(NewStr3,"com") = 0) And (InStr(NewStr3,"be") = 0) And (InStr(NewStr3,"net") = 0) Then
'You can always add more . adresses.
MsgBox "*" & Email & "* is a valid E-M@il adress!",16 + 4096,Titel + " - Error"
EmailValidate
End If
If Len(NewStr3) => 5 Then
MsgBox "*" & Email & "* is a valid E-M@il adress!",16 + 4096,Titel + " - Error"
EmailValidate
End If
EmailOK = True
Loop
MsgBox "Your  E-M@il adress: *" &Email& "* is accepted!","32",Titel
Wscript.Quit
End Sub
<message edited by Jori on Monday, December 21, 2009 5:07 AM>
 
#1
    ebgreen

    • Total Posts : 8225
    • Scores: 98
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: online
    Re:E-M@il Validation. Monday, December 21, 2009 5:33 AM (permalink)
    0
    Thanks for sharing, but wouldn't this (courtesy of Ginolard) be easier:

    Function EmailAddress(input) 
        EmailAddress = False
        Set objregEx = New RegExp
        objregEx.Pattern ="^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$"
        objregEx.IgnoreCase = True
        retVal = objregEx.Test(input)
        If Not retVal Then 
            Exit Function
        Else 
            EmailAddress = True
        End If
    End Function
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
     
    #2
      Jori

      • Total Posts : 5
      • Scores: 0
      • Reward points : 0
      • Joined: 11/25/2009
      • Status: offline
      Re:E-M@il Validation. Monday, December 28, 2009 9:41 PM (permalink)
      0
      Yes alot easier :), but there are two reasons why I prefer my code.

      1. There are more options to edit the validation. If you want you can put a DSN Server database to it. And you can specified the illegal character list.

      2. Its a good string editing practice.

      Btw, Thanks for your comment. :-)

      Jori.
       
      #3

        Online Bookmarks Sharing: Share/Bookmark

        Jump to:

        Current active users

        There are 0 members and 1 guests.

        Icon Legend and Permission

        • New Messages
        • No New Messages
        • Hot Topic w/ New Messages
        • Hot Topic w/o New Messages
        • Locked w/ New Messages
        • Locked w/o New Messages
        • Read Message
        • Post New Thread
        • Reply to message
        • Post New Poll
        • Submit Vote
        • Post reward post
        • Delete my own posts
        • Delete my own threads
        • Rate post

        2000-2012 ASPPlayground.NET Forum Version 3.9