zoukankan      html  css  js  c++  java
  • 来个异步查询用户名是否存在

    来个异步查询用户名是否存在
    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");
            }
        }
  • 相关阅读:
    windows.open()参数列表
    HttpHandler HttpModule入门篇
    使用ASP.NET上传图片汇总
    HTTPModule生命周期与页面执行模型
    自定义日期输入控件解决需要用户输入日期的麻烦控制
    使用WebService进行异步通信
    制作WEB在线编辑器插入HTML标签
    使用UDP非连线式发送接收数据(聊天室模式)
    asp.net中获取远端WEB页内容
    在winform里怎么调用WebBrowser控件里的脚本 (转自思归呓语)
  • 原文地址:https://www.cnblogs.com/kangwl/p/2325506.html
Copyright © 2011-2022 走看看