var state = false;
            $(document).ready(function(){
            
               $("#txt2UserName").focus();
               $("#txt2UserName").keyup(function(){
               $.ajax({
                      //提交數據的類型 POST GET
                      type:"GET",
                      //提交的網址
                     url: "reg.aspx",
                      //提交的數據
                      data:{isAjax:"true",Name:$("#txt2UserName").val()},//$("#txt2UserName").val()
                      //返回數據的格式
                      datatype: "text",//"xml", "html", "script", "json", "jsonp", "text".
                      //在請求之前調用的函數
                      //beforeSend:function(){$("#idMessage").html("logining");},
                      //成功返回之后調用的函數            
                    //  success:function(data){
                   //  $("#idMessage").html(decodeURI(data));           
                      //}   ,
                      //調用執行后調用的函數
                      complete: function(XMLHttpRequest, textStatus){
                         //alert(XMLHttpRequest.responseText);
                         var mes = XMLHttpRequest.responseText;
                         state =mes=="0";
                         mes = mes=="0"?("用戶名可以注冊!"):("用戶名已存在不能注冊!");
                         $("#idMessage").html(mes);
                          //HideLoading();
                      },
                      //調用出錯執行的函數
                     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 閱讀(2627) 評論(2)  編輯  收藏

          FeedBack:
          # re: jquery 注冊驗證例子
          2011-03-03 08:34 | fhfh
          hfdhdh  回復  更多評論
            
          # re: jquery 注冊驗證例子
          2011-09-07 14:05 | 愛愛愛
          AA  回復  更多評論
            

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


          網站導航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 三亚市| 右玉县| 绥宁县| 油尖旺区| 尚义县| 都昌县| 佛教| 武城县| 同心县| 崇信县| 横山县| 云龙县| 临高县| 永善县| 广州市| 岳普湖县| 炎陵县| 鄂尔多斯市| 都匀市| 凤翔县| 嘉鱼县| 松原市| 扎兰屯市| 贡嘎县| 顺义区| 乃东县| 福鼎市| 九江市| 阳信县| 溆浦县| 方城县| 朝阳市| 乡城县| 阿拉善右旗| 平遥县| 河南省| 威宁| 商河县| 庐江县| 大悟县| 莱阳市|