注册页面检验用户名代码(asp+ajax结合)

yoken 阅读:1451 2007-10-15 01:35:00 评论:0
<script type="text/javascript">
    function createxmlhttprequest()
    {
        var xmlhttp=false;
        try
        {
            xmlhttp=new ActiveXObject('Msxm12.XMLHTTP');
        }
        catch(e)
        {
            try
            {
                xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch(e)
            {
                try
                {
                    xmlhttp=new XmlHttpRequest();
                }
                catch(e)
                {
                }
            }
         }
        return xmlhttp;
    }
    function checkuser()
    {
        var xmlhttp=createxmlhttprequest();
        var username=document.getElementById('UserLogName');
        xmlhttp.open('get','CheckUserIs.asp?UserName='+username.value);
        xmlhttp.onreadystatechange=function()
        {
            if(xmlhttp.readyState==4)
            {
            
                if(xmlhttp.status==200)
                {
                    if(xmlhttp.responseText=="1")
                    {   
                        document.getElementById("IsOkUserName").innerText='该用已存在';
                    }
                    else
                    {
                        document.getElementById("IsOkUserName").innerText='可以注册';
                    }
                }
            }
        }
        xmlhttp.send(null);
    }


function checkuseremail()
    {
        var xmlhttp=createxmlhttprequest();
        var username=document.getElementById('UserEmail');
        xmlhttp.open('get','CheckUserEmail.asp?UserEmail='+username.value);
        xmlhttp.onreadystatechange=function()
        {
            if(xmlhttp.readyState==4)
            {
            
                if(xmlhttp.status==200)
                {
                    if(xmlhttp.responseText=="1")
                    {   
                        document.getElementById("IsOkUserEmail").innerText='该邮箱己存在';
                    }
                    else
                    {
                        document.getElementById("IsOkUserEmail").innerText='可以注册';
                    }
                }
            }
        }
        xmlhttp.send(null);
    }

</script>


<input checkuser();" type="text" size="16" maxlength="16" style="height:18">


<input checkuseremail();" type="text" size="30" maxlength="50" style="height:18">
CheckUserIs.asp文件   
    
  <!--#include   file="inc/conn.asp"-->   
  <%   
  IsUserName=request("UserName")   
  set   rs=conn.execute("select   UserLogName   from   Users   where   rtrim(UserLogName)='"+trim(IsUserName)+"'")   
  if   not(rs.eof   and   rs.bof)   then   
  response.Write   "1"   
  else   
  response.Write   "0"   
  end   if   
  rs.close     
  %>

转载保留链接!网址:https://80920140.com/post/46.html

标签:微软
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源; 2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任; 3.作者投稿可能会经我们编辑修改或补充。

发表评论
搜索
排行榜
关注我们

扫一扫关注我们,了解最新精彩内容