What can I do if you do not submit or jump to the query button when the registered user name already exists?

Source: Internet
Author: User
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 }}}}

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.