;(function(){ var ajaxSub = false, showError = function(msg){ if(msg){ $('#er_txt').html(msg).show(); }else{ $('#er_txt').html('').hide(); } }, checkpwd = function(that){ var txt = that.val(); txt = txt.replace(/(^s*)|(s*$)/g,''); if(!txt){ showError('原密码不能为空'); return; } if(txt.length < 6 || txt.length > 20){ showError('密码长度为6-20个字符'); return; } showError(0); }, newPwd = function(that){ var pwd = that.val(), reg = /(.)11/; if(!pwd){ showError('密码不能为空'); return false; } if(pwd.length < 6 || pwd.length > 20){ showError('请控制您的密码在6-20之内'); return false; } if(pwd.length > 0 && reg.test(pwd) ){ showError('密码含有连续相同字符'); return false; } showError(0); return true; }, rNewPwd = function(that){ var password = $('#newPwd').val(), password2 = that.val();; if(!password2){ showError('请再次输入您的密码'); return false; } if(password != password2){ showError('两次输入的密码请保持一致!'); return false; } showError(0); return true; }, subFun = function(){ var data = {}; checkpwd($('#oldPwd')); if( !newPwd($('#newPwd')) ) return; if( !rNewPwd($('#rNewPwd')) ) return; if(ajaxSub) return; ajaxSub = true; data.o = $('#oldPwd').val(); data.n = $('#newPwd').val(); data.r = $('#rNewPwd').val(); $.ajax({ type : 'get', //url : ucWap.dataUrl+'wap/resetpwd/', url : 'http://www.example.com/resetpwd/o/'+data.o+'/n/'+data.n+'/r/'+data.r+'', data : data, dataType : 'jsonp', success : function(data){ if(data.status == 'success'){ $('#mdPwd_b').hide(); $('#mdPwd_a').show(); }else{ showError(data.msg); } ajaxSub = false; }, }); return false; }; $(document).delegate('#oldPwd','blur',function(){ checkpwd($(this)); }).delegate('#newPwd','blur',function(){ newPwd($(this)); }).delegate('#rNewPwd','blur',function(){ rNewPwd($(this)); }).delegate('#mdPwd','click',function(){ subFun(); }); }());