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
International

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.

.NET Developer
Steinman Recruiting Associates
US-PA-York

Justtechjobs.com Post A Job | Post A Resume

Published: Wednesday, May 19, 1999

An Email Validation Script
By Ben Durbin


Here is yet another great server-side email validation routine. The code is in text format via a link at the bottom.

function chkEmail(theAddress)
   ' checks for a vaild email
   ' returns 1 for invalid addresses
   ' returns 0 for valid addresses
   dim atCnt
   chkEmail = 0

   ' chk length
   if len(theAddress) < 5  then 
      ' a@b.c should be the shortest an
      ' address could be
      chkEmail = 1
 
   ' chk format
   ' has at least one "@"
   elseif instr(theAddress,"@") = 0 then
      chkEmail = 1
 
   ' has at least one "."
   elseif instr(theAddress,".") = 0 then
      chkEmail = 1
 
   ' has no more than 3 chars after last "."
   elseif len(theAddress) - instrrev(theAddress,".") > 3 then
      chkEmail = 1
 
   ' has no "_" after the "@"
   elseif instr(theAddress,"_") <> 0 and _
       instrrev(theAddress,"_") > instrrev(theAddress,"@")  then
      chkEmail = 1

   else
      ' has only one "@"
      atCnt = 0
      for i = 1 to len(theAddress)
         if  mid(theAddress,i,1) = "@" then
            atCnt = atCnt + 1
         end if
      next
 
      if atCnt > 1 then
         chkEmail = 1
      end if

      ' chk each char for validity
      for i = 1 to len(theAddress)
        if  not isnumeric(mid(theAddress,i,1)) and _
		(lcase(mid(theAddress,i,1)) < "a" or _
		lcase(mid(theAddress,i,1)) > "z") and _
		mid(theAddress,i,1) <> "_" and _
		mid(theAddress,i,1) <> "." and _
		mid(theAddress,i,1) <> "@" and _
		mid(theAddress,i,1) <> "+" and _
		mid(theAddress,i,1) <> "-" then
            chkEmail = 1
        end if
      next
  end if
end function

Attachments:

  • Code in Text Format

    Happy Programming!


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



  • JupiterOnlineMedia

    internet.comearthweb.comDevx.commediabistro.comGraphics.com

    Search:

    Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

    Jupitermedia Corporate Info


    Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

    Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers