用户申请时对Email帐号的检测

Email帐号*

在用户申请注册时对EMAIL帐号进行检测,以判断此Email能否正确注册.大部分的论坛都有这个功能,可是当我找来动网的代码进行看的时候竟找不到相应的功能是怎么实现的.很是不爽,只好自己写了.

实现方式如下:
1 判断用户输入的Email帐号是不是有效
2 判断此帐号是不是已经注册了
3 给出注册成功或是出错的原因

其中1中要首先取页面的输入值,代码:

function chk_email()
{
var url
var email=document.form1.mail.value
if (email=='')
  { alert('email不能为空
!') }
else
  {
    url 
= 'usercheck.asp?email=+ email
    window.open(url,'chk','status
=no,toolbar=no,menubar=no,location=no,width=300,height=150')
  }
}

然后在打开的窗口中检验Email的有效性,实现函数:
function IsValidEmail(email)
Dim names
Dim name
Dim i
Dim c
IsValidEmail 
= true
names 
= Split(email, "@")
if UBound(names) <> 1 then
   IsValidEmail 
= false
   
exit function
end if
for each name in names
   
if Len(name) <= 0 then
     IsValidEmail 
= false
     
exit function
   
end if
   
for i = 1 to Len(name)
     c 
= Lcase(Mid(name, i, 1))
     
if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
       IsValidEmail 
= false
       
exit function
     
end if
   
next
   
if Left(name, 1= "." or Right(name, 1= "." then
      IsValidEmail 
= false
      
exit function
   
end if
next
if InStr(names(1), "."<= 0 then
   IsValidEmail 
= false
   
exit function
end if
= Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
   IsValidEmail 
= false
   
exit function
end if
if InStr(email, ".."> 0 then
   IsValidEmail 
= false
end if
end function

然后在过滤字符串之后,查询数据库判断此用户是不是已经存在.给出提示.
Over!
[ASP中实现]
原文地址:https://www.cnblogs.com/lbk/p/99532.html