《2022年ASP判断E-Mail的合法性以及过滤邮箱字符源码精华教程.docx》由会员分享,可在线阅读,更多相关《2022年ASP判断E-Mail的合法性以及过滤邮箱字符源码精华教程.docx(10页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、2022年ASP判断E-Mail的合法性,以及过滤邮箱字符源码精华教程'函数名:chk_Email()'返回值:布尔值(True为通过,False为未通过)'参数:email(须要推断的email,类型:字符串) Type_1(是否须要推断之后的domain,类型:布尔值)'Type_2(是否只能是特定域的E-Mail注册,类型:布尔值) Type_3(一个E-Mail是否只能注册一次,类型:布尔值) Const C_maildomain=.com,.net,.org,.gov,.edu,.cn,.cc,.biz,.info '电子邮件可接受的domai
2、nConst C_Lockdomain=,loster.org '特定的域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=Mi
3、d(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) Te
4、mp=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=Tr
5、ue Exit For End If Next Erase Reader If At=False Then Chk_Email=False Exit Function End If End If If Type_2=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 Temp= For i=k+1 To Len(Email_1) Temp=Temp+Mid(Email_1,i,1) Next Temp=Cstr(Trim(Temp) At=False For
6、 i=0 To R_Reader(C_Lockdomain,) If Temp=Reader(i) Then At=True Exit For End If Next Erase Reader If At=False Then Chk_Email=False Exit Function End If End If If Type_3=True Then Dim j Call Greate_UserDb() Call Create_Rs(Select * from User_Basic_Info where User_Email='Email_1',1,1,User) If Rs
7、.Bof=False Then Chk_email=False Call Close_Rs() Call Close_UserDb() Exit Function End If Call Close_Rs() Call Close_UserDb() End If chk_email=True End Function Dim User_Db,User_DriverDim User_ConnUser_Db=Data/userdata.mdb'建立User_conn的过程Sub Greate_UserDb() User_Driver=driver={Microsoft Acces
8、s Driver (*.mdb)} User_Driver=User_Driver;dbq=server.mappath(User_Db) 'Response.Write (User_Driver) Set User_Conn = Server.CreateObject(ADODB.Connection) User_Conn.Open(User_Driver) End Sub'关闭User_conn的过程Sub Close_UserDb() User_Conn.Close Set User_Conn=Nothing End SubDim ReaderDim Rs'读取常数,并将每个常数保存在reader数组中,参数:R_Str(常数串),F_Str(分隔符),返回值:Reader数组的下标Function R_Reader(R_Str,F_Str) Dim i If R_Str= Or F_Str= Then Exit Function End If Reader=Split(R_Str,F_Str) For i=0 To Ubound(Reader,1) Reader(i)=Cstr(Trim(Reader(i) Next R_Reader=Ubound(Reader,1) End Function(出处: