ajax驗證使用者名稱和找回密碼參考

來源:互聯網
上載者:User

標籤:style   blog   http   java   color   os   

 1 // JavaScript Document 2 function chkname(form){ 3     var user = form.user.value; 4     if(user == ‘‘){ 5         alert(‘請輸入使用者名稱‘); 6         form.user.focus(); 7         return false; 8     }else{ 9         var url = "foundpwd.php?user="+user;10         xmlhttp.open("GET",url,true);11         xmlhttp.onreadystatechange = function(){12         if(xmlhttp.readyState == 4){13                 var msg = xmlhttp.responseText;14                 if(msg == ‘0‘){15                     alert(‘沒有該使用者,請重新尋找!‘);16                     form.user.select();17                     return false;18                 }else{19                     document.getElementById(‘first‘).style.display = ‘none‘;20                     document.getElementById(‘second‘).style.display = ‘‘;21                     document.getElementById(‘question‘).innerHTML = msg;22                 }23             }24         }25         xmlhttp.send(null);26     }27 }28 function chkanswer(form) {29     var user = document.getElementById(‘user‘).value;30     var answer = form.answer.value;31     if(answer == ‘‘){32         alert(‘請輸入提示問題‘);33         form.answer.focus();34         return false;35     }else{36         var url = "foundpwd.php?user="+user+"&answer="+answer;37         xmlhttp.open("GET",url,true);38         xmlhttp.onreadystatechange = function(){39             if(xmlhttp.readyState == 4){40                 var msg = xmlhttp.responseText;41                 if(msg == ‘0‘){42                     alert(‘問題回答錯誤‘);43                     form.answer.select();44                     return false;45                 }else{46                     document.getElementById(‘second‘).style.display = ‘none‘;47                     document.getElementById(‘third‘).style.display = ‘‘;48                 }49             }50         }51         xmlhttp.send(null);52     }53 }54 function chkpwd(form){55     var user = document.getElementById(‘user‘).value;56     var pwd1 = form.pwd1.value;57     var pwd2 = form.pwd2.value;58     if(pwd1 == ‘‘){59         alert(‘請輸入密碼‘);60         form.pwd1.focus();61         return false;62     }63     if(pwd1.length < 6){64         alert(‘密碼輸入錯誤‘);65         form.pwd1.focus();66         return false;67     }68     if(pwd1 != pwd2){69         alert(‘兩次密碼不相等‘);70         form.pwd2.select();71         return false;72     }73     var url = "foundpwd.php?user="+user+"&password="+pwd1;74     xmlhttp.open("GET",url,true);75     xmlhttp.onreadystatechange = function(){76         if(xmlhttp.readyState == 4){77             var msg = xmlhttp.responseText;78             if(msg == ‘1‘){79                 alert(‘密碼修改成功,請重新登入‘);80                 window.close();81             }else{82                 alert(msg);83             }84         }85     }86     xmlhttp.send(null);87 }
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.