Server-Side e-mail Validation with ASP.

Thursday Apr 22nd 1999 by ServerWatch Staff
Share:

This one is very simple.... but there is always someone trying to reach this code.... I hope you understand the code.

Joco Vieira

This one is very simple.... but there is always someone trying to reach this code.... I hope you understand the code.

1. First I have created a variable that at the end could give me if the validation is ok or not 'goby'.

2.
So, I have used the function InStr that gives me True Or False about any character inside a String.

3. So here is the code, use it as you want

<%

Dim goby
goby = 0 //Starting the goby string
    I f Len(session("emailfrom")) <= 5 Then goby = 1// if the len is minor than 5 then it can't be an email (a@a.c)
     else
        If InStr(1, session("emailfrom"), "@", 1) < 2 Then // if it doesn't findo one @ then, not ok again
             goby = 1
                Else
                   If InStr(1,session("emailfrom"), ".", 1) < 4 The // must have a '.' too
                       goby = 1
                   End If
        End If
End If
If goby <> 0 then // well , if goby <> 0 then something must be wrong
     response.write "Bad E-Mail..."
End If

Share:
Home
Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved