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 }