ASP to determine the legality of e-mail, and filter mailbox characters
Source: Internet
Author: User
Original Author: Loster
' Function name: Chk_email ()
' Return value: Boolean (True to pass, false to failed)
' Parameters: Email (email to be judged, type: string) type_1 (whether to judge domain after @, type: Boolean)
' Type_2 (can only be a specific domain of e-mail registration, type: Boolean) type_3 (an e-mail can only register once, type: Boolean)
Const c_maildomain= ". Com,.com.cn,.net,.net.cn,.org,.org.cn,.gov,.gov.cn,.edu,.edu.cn,.cn,.cc,.biz,.info" ' e-mail acceptable in domain
Const c_lockdomain= "bit.edu.cn,loster.org" ' specific domain
Function Chk_email (Email,type_1,type_2,type_3)
Dim i,k
Dim at
Dim email_1,temp
If email= "" Then
Chk_email=false
Exit Function
End If
Email_1=cstr (Trim (email))
If Len (email_1) <5 Then
Chk_email=false
Exit Function
End If
At=false
For I=1 to Len (Email_1)
Temp=mid (email_1,i,1)
If temp= "@" Then
At=true
Exit for
End If
Next
If At=false Then
Chk_email=false
Exit Function
End If
K=0
For I=1 to Len (Email_1)
Temp=mid (email_1,i,1)
If temp= "." Then
K=k+1
End If
Next
If k=0 Or k>2 Then
Chk_email=false
Exit Function
End If
If type_1=true Then
For I=1 to Len (Email_1)
Temp=mid (email_1,i,1)
If temp= "@" Then
K=i
Exit for
End If
Next
For I=k to Len (Email_1)
Temp=mid (email_1,i,1)
If temp= "." Then
K=i
Exit for
End If
Next
Temp= ""
For I=k to Len (Email_1)
Temp=temp+mid (email_1,i,1)
Next
Temp=cstr (Trim (Temp))
At=false
For i=0 to R_reader (C_maildomain, ",")
If Temp=reader (i) Then
At=true
Exit for
End If
Next
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