vinpkl Posted December 31, 2008 Share Posted December 31, 2008 hi all i m using the below script to check live check user in database. This script works fine for me. I just need to have the same effect when the user enters the username and his cursor is still in the input box. At present to show mesage whether the username exists or not the customer has to enter the username and then put the cursor in the next input field. <script type="text/javascript"> function toggle_username(userid) { if (window.XMLHttpRequest) { http = new XMLHttpRequest(); } else if (window.ActiveXObject) { http = new ActiveXObject("Microsoft.XMLHTTP"); } handle = document.getElementById(userid); var url = 'ajax.php?'; if(handle.value.length > 0) { var fullurl = url + 'do=check_username_exists&username=' + encodeURIComponent(handle.value); http.open("GET", fullurl, true); http.send(null); http.onreadystatechange = statechange_username; }else{ document.getElementById('username_exists').innerHTML = ''; } } function statechange_username() { if (http.readyState == 4) { var xmlObj = http.responseXML; var html = xmlObj.getElementsByTagName('result').item(0).firstChild.data; document.getElementById('username_exists').innerHTML = html; } } </script> <input id="username" type="text" name="username" onchange="toggle_username('username')" /><br /> <div id="username_exists" style="font-size: 11px;font-weight: bold;color:#FF3300"> </div> vineet Quote Link to comment Share on other sites More sharing options...
xtopolis Posted December 31, 2008 Share Posted December 31, 2008 use an onkeydown event for the trigger Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 31, 2008 Author Share Posted December 31, 2008 use an onkeydown event for the trigger hi xtopolis thanks. it worked great vineet Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.