dwl10 Posted January 27, 2009 Share Posted January 27, 2009 Hi, im quite new to ajax, so any help would be appreciated. Im building a registration page. when all of the information has been entered into the fields I would like the form to process a php page which should produce text saying "registered" or "user ID exists". my html <body> <div class="header"> </div> <p><b><h1>User Registration</h1></b></p> <form name="register" action="RegisterNewUser.php"> <p>User ID: <input type="text" name="userID" value="" onMouseMove="javascript:validate();"> <div id="user"></div></p> <p><br>First Name: <input type="text" name="Name" value="" onMouseMove="javascript:validate();"> <div id="name"></div></p> <p><br>Surname: <input type="text" name="Surname" value="" onMouseMove="javascript:validate();"> <div id="surname"></div></p> <p><br>Password: <input type="password" name="passWD" value="" onMouseMove="javascript:validate();"></p> <p><br>Retype Password: <input type="password" name="repassWD" value="" onMouseMove="javascript:validate();"><div id="password"></div></p> <br> <input type="Submit" name="Submit" value="Submit" onClick="ajax();"> <input type="reset" name="Reset" value="Reset"> </form> </body> my javascript <script type="text/javascript"> function ajax(){ var req; try{ req = new XMLHttpRequest(); } catch (e){ try{ req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ alert("Your browser needs updating."); return false; } } } req.onreadystatechange = function() { if(req.readyState == 4) { if(req.status == 200) var response=request1.responseText; } } req.open("GET", "RegisterNewUser.php", true); req.send(null); } can anyone shed any light on where im going wrong? the submit button works how I want it to, but i do not want to have to press submit. thank you in advance. Link to comment https://forums.phpfreaks.com/topic/142621-submit-form/ Share on other sites More sharing options...
priti Posted January 29, 2009 Share Posted January 29, 2009 In my view: when user finished entering password i.e Last form field to be filled by user then in your validate() function instantiate the ajax request to do this . Link to comment https://forums.phpfreaks.com/topic/142621-submit-form/#findComment-749341 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.