• 来个异步查询用户名是否存在


    来个异步查询用户名是否存在
    index.aspx

    HTML code 

    <script type="text/javascript" language="javascript">
            function validateloginname()
            {
                var loginname=document.getElementById("Text1").value;

                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                xmlHttp.onreadystatechange=getdata;
                xmlHttp.Open("GET","validate.aspx?loginname="+loginname,true);
                xmlHttp.Send();
            }
            function getdata()
            {
                if(xmlHttp.readystate==4)
                {
                    if(xmlHttp.status==200)
                    {
                        var text=xmlHttp.responseText;
                        if(text=="1")
                        {
                            document.getElementById("td1").innerHTML="用户名已存在";
                            document.getElementById("Text1").style.borderColor="Black";
                            document.getElementById("Text1").focus();
                             document.getElementById("Text1").value="";
                        }
                        else
                        {
                             document.getElementById("td1").innerHTML="OK";
                             document.getElementById("Text1").style.borderColor="Red";
                        }
                    }
                }
            }
        </script>

     <td>
                        <input id="Text1" type="text" runat="server" onblur="validateloginname()" />
                    </td>
                    <td id="td1">
                       
                    </td>




    validate.aspx

    C# code 

        protected void Page_Load(object sender, EventArgs e)
        {
            string loginname = Request.QueryString["loginname"];

            if (loginname == "mcluzhi")
            {
                Response.Write("1");
            }
            else
            {
                Response.Write("0");
            }
        }
  • 相关阅读:
    jsp——学习篇:简单使用CSS
    MongoDB分片式服务器集群配置
    PHP上传文件
    【转】【thinkphp3.x】thinkphp3.x中display方法及show方法的使用
    (转)Mysql用户与权限管理
    MonkeyRunner 之如何获取APP的Package Name和Activity Name
    一个典型的PHP分页实例代码分享
    HTML meta charset 定义网页编码信息
    【转】PHP连接MySQL数据库
    一个漂亮的php验证码类(分享)
  • 原文地址:https://www.cnblogs.com/kangwl/p/2325506.html
Copyright © 2020-2023  润新知