When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles [1.x] [2.0]
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips
Search

Sections:
Book Reviews
Sample Chapters
Commonly Asked Message Board Questions
Headlines from ASPWire.com
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
Web Hosts
XML Info
Information:
Advertise
Feedback
Author an Article
Technology Jobs



















internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers
ASP ASP.NET ASP FAQs Message Board Feedback ASP Jobs
Print this page.

Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

Published: Sunday, April 11, 1999

An Email Validation Routine
By João Vieira



This code will test to make sure that an email address entered by a user is a valid email address.
1. First I have created a variable called goby. If goby equals one, then the validation is ok; otherwise goby will equal 0.

2. The function InStr will be used to determine if a certain character is inside the email string.

3. Here is the code, use

- continued -

it as you want. Happy Programming!

<%

Dim goby
goby = 0 'Initializing goby to 0

'if the len is less than 5 then it can't be an email
'(i.e.: a@a.c)
If Len(session("emailfrom")) <= 5 Then
   goby = 1
End If

If InStr(1, session("emailfrom"), "@", 1) < 2 Then
    'If we find one and only one @, then the
    'email address is good to go.
    goby = 1
Else
    If InStr(1,session("emailfrom"), ".", 1) < 4 Then
        'Must have a '.' too
        goby = 1
    End If
End If

If goby <> 0 then
    'Well , if goby <> 0 then something
    'must be wrong
    response.write "Bad E-Mail..."
End If

%>



Note from Scott Mitchell
The above script shows one way to validate an email address: using ASP on the server. You can also use JavaScript on the client's side, by writing client-side scripting. An example of email validation (as well as many other types of validation) using JavaScript, can be found here:


João Vieira BIO: (email me!)
- Age : 23
- Student And worker (tryin' to finish university, on the last year of the graduation)
- Workin' now at NetGate Portugal
- Programming little stuff since 1989
- Programming HTML since 1996
- Programming JavaScript since 1997, made some experiences with Java.
- Programming ASPs since the Summer of 1997 (yeap, I didn't had nothing to do. Now I love it.)
- Programming ActiveX since 1998
- Webmaster of www.joaovieira.com


Windows Internet Technology | ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs