var state = false;
            $(document).ready(function(){
            
               $("#txt2UserName").focus();
               $("#txt2UserName").keyup(function(){
               $.ajax({
                      //提交數(shù)據(jù)的類型 POST GET
                      type:"GET",
                      //提交的網(wǎng)址
                     url: "reg.aspx",
                      //提交的數(shù)據(jù)
                      data:{isAjax:"true",Name:$("#txt2UserName").val()},//$("#txt2UserName").val()
                      //返回數(shù)據(jù)的格式
                      datatype: "text",//"xml", "html", "script", "json", "jsonp", "text".
                      //在請求之前調(diào)用的函數(shù)
                      //beforeSend:function(){$("#idMessage").html("logining");},
                      //成功返回之后調(diào)用的函數(shù)            
                    //  success:function(data){
                   //  $("#idMessage").html(decodeURI(data));           
                      //}   ,
                      //調(diào)用執(zhí)行后調(diào)用的函數(shù)
                      complete: function(XMLHttpRequest, textStatus){
                         //alert(XMLHttpRequest.responseText);
                         var mes = XMLHttpRequest.responseText;
                         state =mes=="0";
                         mes = mes=="0"?("用戶名可以注冊!"):("用戶名已存在不能注冊!");
                         $("#idMessage").html(mes);
                          //HideLoading();
                      },
                      //調(diào)用出錯執(zhí)行的函數(shù)
                     error: function(){
                          //請求出錯處理
                      }        
                   });
               
               // $("#idMessage").html($(this).val());
               })
            
             $("#BtReg").bind("click",
              function()
              {
              var txt2UserName = $("#txt2UserName").val();
              var txt2Pwd = $("#txt2Pwd").val();
              var txt2APwd = $("#txt2APwd").val();
              var txt2Mail = $("#txt2Mail").val();
              if(txt2UserName.length<1)
              {
              $.messager.alert('信息','用戶名不能為空!');
              $("#txt2UserName").focus();
              return false;
              }
              else if(txt2Pwd.length<1)
              {
              $.messager.alert('信息','密碼不能為空!');
              $("#txt2Pwd").focus();
              return false;
              }
              else if(txt2APwd.length<1)
              {
              $.messager.alert('信息','密碼不能為空!');
              $("#txt2APwd").focus();
              return false;
              }
              else if(txt2APwd!=txt2Pwd)
              {
              $.messager.alert('信息','兩次密碼輸入不一致!');
              $("#txt2APwd").focus();
              return false;
              }
              else if(txt2Mail.length<1)
              {
              $.messager.alert('信息','郵箱不能為空!');
              $("#txt2Mail").focus();
              return false;
              }
              else if(!state)
              {
              $.messager.alert('信息','用戶名已存在請重新注冊!');
              $("#txt2UserName").focus();
              return false;
              }
              else
              {
              return true;
              }
              })
            
            });
            // 顯示信息
               function showMessage(mes)
            {
            $(document).ready(function(){
            $.messager.alert('信息',mes);
            $("#txtUserName").foucs();
            })
            }
          posted on 2010-08-12 10:22 sanmao 閱讀(2619) 評論(2)  編輯  收藏

          FeedBack:
          # re: jquery 注冊驗(yàn)證例子
          2011-03-03 08:34 | fhfh
          hfdhdh  回復(fù)  更多評論
            
          # re: jquery 注冊驗(yàn)證例子
          2011-09-07 14:05 | 愛愛愛

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 大化| 东乡| 五台县| 仙游县| 海伦市| 江川县| 塔河县| 沙雅县| 土默特左旗| 斗六市| 山西省| 利辛县| 芒康县| 颍上县| 建始县| 安宁市| 伊宁市| 新闻| 陇西县| 永善县| 枣庄市| 新野县| 建阳市| 双鸭山市| 方山县| 沙坪坝区| 榆林市| 东乡县| 礼泉县| 赣榆县| 迁西县| 通城县| 阿荣旗| 竹山县| 大埔区| 买车| 朔州市| 阆中市| 紫阳县| 苗栗市| 鸡泽县|