Determine if an email address is valid

Source: Internet
Author: User
Tags chr valid
When you write a page with ASP, if it involves sending a message, you will normally be asked to enter your email address. Wrong email address often brings a lot of unnecessary trouble, use the following function IsValidEmail can determine an email address is valid.
Function Source 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 ()) and (ATCHR <= Chr ()) Then Specialflag = True
If (ATCHR = CHR ()) or (ATCHR = Chr) or (ATCHR >= (CHR)) 123 Then = True
If (ATCHR >= Chr ()) and (ATCHR <= Chr ()) Then Specialflag = True
If (ATCHR >= Chr ()) and (ATCHR <= Chr ()) 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
%>
Use examples:
IsValidEmail (" my_263_email@263.net ") returns ture
IsValidEmail (" zh99wj@tonghua.com.cn ") returns ture
IsValidEmail ("Myemail263.net") returns false
IsValidEmail (" my_263_email@263 ) returns false
Note that the function simply determines whether the email address format is valid, but does not check that the address does exist.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.