Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · Web Hosting Plans · Faisal Khan's Blog · Contact
Search Stardeveloper.com
Stardeveloper RSS Feed
Newsletter
Enter your email address below to be informed every time a new article is posted at Stardeveloper.com:

You can follow Faisal Khan on Twitter
Article Categories
.NET  .NET
  ASP (16)
  ASP.NET (41)
  ADO (16)
  ADO.NET (10)
  COM (6)
  Web Services (4)
  C# (1)
  VB.NET (3)
  IIS (2)

J2EE  J2EE
  JSP (15)
  Servlets (9)
  Web Services (1)
  EJB (4)
  JDBC (4)
  E-Commerce (1)
  J2ME (1)
  Products (1)
  Applets (1)
  Patterns (1)
Log In
UserName Or Email:

Password:

Auto-Login:

Miscellaneous Links
  Submit Article

Hosted by Securewebs.com
 
Home : .NET : ASP : Server Side Email Addresses Validation using VBScript
 

We are declaring i to equal the length of the second element of the names array minus the numeric position of the first occurrence of a period, starting from the right end of the string. If variable i does not equal "2" or "3", then the email address is invalid. What this little snippet does here is checking for is to see how long the user specified their TLD (Top-Level Domain [i.e. -- .com,.net,.org,etc.]) to be. And since top level domains do not exist that have more than three characters, the period cannot be more than three characters from the left and the entered email address be valid. If it is determined to be an invalid email address, the function is exited.

  if InStr(email, "..") > 0 then
   isitvalid=false
  end if
  if InStr(email, "..") > 0 then
   isitvalid=false
  end if

If anywhere in the passed string is the substring "..", the email address is invalid because a valid email address cannot have two periods right together. No "exit function" statement is necessary here because the function is finally over.

Summary :

I hope that I've taught you a few things over the course of this tutorial. Additionally, you may be wondering how to execute the function. Its really very simple: just use the following line of code:

  IsValidEmail("charles@dimsdale.com")

Of course, you can replace "charles@dimsdale.com" with your own email address, or more effectively the name of a variable that holds a user entered email address.

If you have any questions, feel free to write me at charles@dimsdale.com or post a question in the FORUM. I'd be glad to help.

We are declaring i to equal the length of the second element of the names array minus the numeric position of the first occurrence of a period, starting from the right end of the string. If variable i does not equal "2" or "3", then the email address is invalid. What this little snippet does here is checking for is to see how long the user specified their TLD (Top-Level Domain [i.e. -- .com,.net,.org,etc.]) to be. And since top level domains do not exist that have more than three characters, the period cannot be more than three characters from the left and the entered email address be valid. If it is determined to be an invalid email address, the function is exited.

  if InStr(email, "..") > 0 then
   isitvalid=false
  end if
  if InStr(email, "..") > 0 then
   isitvalid=false
  end if

If anywhere in the passed string is the substring "..", the email address is invalid because a valid email address cannot have two periods right together. No "exit function" statement is necessary here because the function is finally over.

Summary :

I hope that I've taught you a few things over the course of this tutorial. Additionally, you may be wondering how to execute the function. Its really very simple: just use the following line of code:

  IsValidEmail("charles@dimsdale.com")

Of course, you can replace "charles@dimsdale.com" with your own email address, or more effectively the name of a variable that holds a user entered email address.

If you have any questions, feel free to write me at charles@dimsdale.com or post a question in the FORUM. I'd be glad to help.


Previous ( 1 Gone )( No Further Pages )

See all comments and questions (post-ad) posted for this tutorial.


Related Articles
  1. Sending E-Mails with ASP Pages
  2. Basic Active Server Pages Tutorial for beginners
  3. Extremely useful ASP functions
  4. Uploading Files to the Server Hard Disk using plain ASP
  5. Working with Drives, Folders and Files in ASP
  6. Object Oriented Design Principles in Visual Basic
  7. Beginning E-Commerce : Object Oriented Programming
  8. Professional Windows DNA
  9. An ASP Tutorial to create your own News Letter
  10. Reading XML file with ASP

Comments/Questions ( Threads: 5, Comments: 6 )
    Contains 1 or more replies by the Author of this Article.
    Contains 1 or more replies by Faisal Khan.

  1. how to validate email using VBScript when we support UNICODE
  2. Different form of Email Validation
  3. Wrong email validation characters
  4. typo in original code
  5. E.mail validation ( 1 Reply ) This thread contains 1 reply by Faisal Khan.

Post Comments/Questions

In order to post questions/comments, you must be logged-in. If you are not a member yet, then signup, otherwise login. Once you login then come back to this page and you'll see a form right here which will allow you to post comments/questions.

Please note, one of the benefits of signing up is to be notified immediately by email everytime you receive a reply to the thread you have subscribed to.

 
© 1999 - 2009 Stardeveloper.com, All Rights Reserved.