Ajax verification username and password retrieval reference

Source: Internet
Author: User
1 // JavaScript document 2 function chkname (form) {3 var user = form. user. value; 4 If (user = '') {5 alert ('enter your username'); 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 ('this user does not exist, please search again! '); 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 Lert ('Enter the prompt question '); 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 ('problem answering error'); 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 (Nu Ll); 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 ('enter password'); 60 form. pwd1.focus (); 61 Return false; 62} 63 If (pwd1.length <6) {64 alert ('incorrect password entered '); 65 form. pwd1.focus (); 66 return false; 67} 68 if (pwd1! = Pwd2) {69 alert ('two passwords are not equal '); 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 ('password modified successfully, please log on again '); 80 window. close (); 81} else {82 alert (MSG); 83} 84} 85} 86 XMLHTTP. send (null); 87}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.