Ask the experts to check if the registered user name already exists and the button does not submit or jump. how can this problem be achieved? PHPcode & lt; formid = & quot; form1 & quot; onsubmit = & quot; returnhostvalid (); & quot; method = & quot; post & quot; name = & quot; ask the Masters about form. if the user name already exists, the button is not submitted and the user name does not jump. how can this problem be solved?
PHP code
JScript code
// JavaScript Documentvar XHR;function createXHR(){ if(window.ActiveXObject){ XHR=new ActiveXObject('Microsoft.XMLHTTP'); }else if(window.XMLHttpRequest){ XHR=new XMLHttpRequest(); }}function checkname(){ var username=document.form1.host.value; createXHR(); XHR.open("GET","./checkname.php?id="+username,true); XHR.onreadystatechange=byhongfei; XHR.send(null);}function byhongfei(){ if(XHR.readyState == 4){ if(XHR.status == 200){ var textHTML=XHR.responseText; document.getElementById('msg').innerHTML=textHTML; } }}
PHP code
When a user name exists, how does the registration button realize unavailability? now, the user name also jumps to index. php? Reg
------ Solution --------------------
JScript code
Document. getElementById ("button"). disabled = 'true'; // disable document. getElementById ("button"). removeAttribute ("disabled"); // restore
------ Solution --------------------
JScript code
Function byhongfei () {if (XHR. readyState = 4) {if (XHR. status = 200) {var textHTML = XHR. responseText; document. getElementById ('MSG '). innerHTML = textHTML; if (textHTML = "username already exists") {document. getElementById ("button "). disabled = 'true'; // disabled }}}}