Home | Advertising Info131 USERS CURRENTLY ONLINE   
PowerASP

try aspprotect !!
the premier asp based user management system !!

   Site Search Contact Us Friday, February 03, 2012  
 
 







DISCUSSION ARCHIVES
DISCUSSION ARCHIVES 2
DISCUSSION ARCHIVES 3
BLOG

 
Try a free httpZip trial now and compress for less!


We didn't realize
the site was so popular.

Other Stuff
 
 


IsValidEmail Function




This function was designed by my Co-worker Tim Lasek. He makes all sorts of cool functions. It is designed to check for valid possible emails. It does not check to see if the email really exists. Valid email names vary with different email servers. This tries to cover must situations and is somewhat lenient. I have been using this on form results for a while now and have not had any complaints yet. At least it weeds out the impossible emails that waste our time.

Please Note:   There may be some valid emails this won't allow depending upon the situation. Some email servers allow some email names that 95% of the others don't. You may need to modify this function a bit to allow stuff like that if you want. This isn't perfect and I'm sure an improved version will go up after some feedback. Be helpful and send us your problem and we will modify the function after investigating your comments.

Function IsValidEmail(Email)

Usage:    IsValidEmail("somedude@provider.net")

Result:    True

Below is the Function Source Code and Example Usage Code

<%
Function IsValidEmail(Email)
ValidFlag = False
If (Email <> "") And (InStr(1, Email, "@") > 0) And (InStr(1, Email, ".") > 0) Then
atCount = 0
SpecialFlag = False
For atLoop = 1 To Len(Email)
atChr = Mid(Email, atLoop, 1)
If atChr = "@" Then atCount = atCount + 1
If (atChr >= Chr(32)) And (atChr <= Chr(44)) Then SpecialFlag = True
If (atChr = Chr(47)) Or (atChr = Chr(96)) Or (atChr >= Chr(123)) Then SpecialFlag = True
If (atChr >= Chr(58)) And (atChr <= Chr(63)) Then SpecialFlag = True
If (atChr >= Chr(91)) And (atChr <= Chr(94)) Then SpecialFlag = True
Next
If (atCount = 1) And (SpecialFlag = False) Then
BadFlag = False
tAry1 = Split(Email, "@")
UserName = tAry1(0)
DomainName = tAry1(1)
If (UserName = "") Or (DomainName = "") Then BadFlag = True
If Mid(DomainName, 1, 1) = "." then BadFlag = True
If Mid(DomainName, Len(DomainName), 1) = "." then BadFlag = True
ValidFlag = True
End If
End If
If BadFlag = True Then ValidFlag = False
IsValidEmail = ValidFlag
End Function
%>

<%= "somedude@provider.net = " & IsValidEmail("somedude@provider.net") & "<br>" %>
<%= "somedudeprovider.net = " & IsValidEmail("somedudeprovider.net") & "<br>" %>
<%= "somedude@providernet = " & IsValidEmail("somedude@providernet") & "<br>" %>



Here are some examples of what this functions allows for valid emails.

somedude@provider.net = True
somedudeprovider.net = False
somedude@providernet = False
somed@ude@provider.net = False
some-dude@provide_r.net = True
somedude@provider.edu.org = True
some.dude@provider.edu.org = True

some&dude@provider.net = False
s*(ome.dude@provider.e{du.org = False
somedude@pro>>>vider.net = False
$somedude@provider.net = False
somedude@provider.net# = False
somedude2@provider.net = True
s@provider.net = True
@provider.net = False
somedude@ = False
somedude@. = False
somedude@.com = False
somedude@provider. = False
somedude_needs@to.get.laid = True
somedude-with_long-name@provider.edu.org = True


   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright © 1998 - 2012 PowerASP.com and Christopher J. Williams
Banner ads ,other site logos, etc are copyright of their respective companies.
STATS Unless otherwise noted - All Rights Reserved.

Active Server Pages asp source code database MS SQL MS Access .mdb adovbs.inc cookies calendar codes sql commands scripts asp programming tutorials iis web server components CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspclassifieds.com, www.powerasp.com,www.cjwsoft.com,www.aspphotogallery.com,www.codewanker.com,www.aspprotect.com,www.aspbanner.com