Note that there are some explanatory texts on larger screens.

plurals
  1. POI need help submitting a form. I do not want the page to refresh, and I do not know how to accomplish this
    primarykey
    data
    text
    <p>I am using a button to submit a form, not a submit button. However, my problem is that I when I press enter, the form does not not submit, so instead i actually have to click the submit button, which can be inconvenient. I am wondering how I can use a button the submit my from without having the page refresh and when I press enter, also have the form submit. I feel like it is a very easy fix that I just can not find. Here is the URL to the page on which the problem is occurring. <a href="http://www.pearlsquirrel.com/register.php" rel="nofollow">http://www.pearlsquirrel.com/register.php</a></p> <p>Here is the code to register.php</p> <pre><code>&lt;div id="centered3"&gt; &lt;h1&gt;&lt;div align='center' style="color:white;"&gt;Join PearlSquirrel&lt;/align&gt;&lt;/h1&gt; &lt;h4&gt;&lt;div id='response'&gt;&lt;/div&gt;&lt;/h4&gt; &lt;script language='javascript' type='text/javascript'&gt; function ajaxregister(){ var ajaxRequest; try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) { try{ ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP'); } catch (e){ // Something went wrong alert('Your browser broke!'); return false; } } } ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay = document.getElementById('response'); ajaxDisplay.innerHTML = ajaxRequest.responseText; } } var username = document.getElementById('username').value; var password = document.getElementById('password').value; var repeatpassword = document.getElementById('repeatpassword').value; var queryString = '?username=' + username + '&amp;password=' + password + '&amp;repeatpassword=' + repeatpassword; ajaxRequest.open('GET', 'ajaxregister.php' + queryString, true); ajaxRequest.send(null); } &lt;/script&gt; &lt;form method='GET'&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; Choose a username: &lt;/td&gt; &lt;td&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function(){ $('#username').keyup(username_check); }); function username_check(){ var username = $('#username').val(); if(username == "" || username.length &lt; 4){ $('#username').css('border', '3px #CCC solid'); $('#tick').hide(); }else{ jQuery.ajax({ type: "POST", url: "check.php", data: 'username='+ username, cache: false, success: function(response){ if(response == 1){ $('#username').css('border', '3px #C33 solid'); $('#tick').hide(); $('#cross').fadeIn(); }else{ $('#username').css('border', '3px #090 solid'); $('#cross').hide(); $('#tick').fadeIn(); } } }); } } &lt;/script&gt; &lt;/head&gt; &lt;script&gt; function nospaces(evt) { var charCode = (evt.which) ? evt.which : event.keyCode if (charCode == 32) return false; return true; } &lt;/script&gt;&lt;body&gt; &lt;input name="username" id="username" type="text" style="height:30px; width:212px;" value='&lt;?php echo $username; ?&gt;' onkeypress="return nospaces(event)"/&gt; &lt;img id="tick" src="tick.png" width="16" height="16"/&gt; &lt;img id="cross" src="cross.png" width="16" height="16"/&gt; &lt;/body&gt; &lt;/html&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Choose a password: &lt;/td&gt; &lt;td&gt; &lt;input type='password' name='password' id='password' style="height: 30px; width:220px;" &gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Repeat your password: &lt;/td&gt; &lt;td&gt; &lt;input type='password' name='repeatpassword' id='repeatpassword' style="height: 30px; width:220px;" &gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; By registering, you agree to the&lt;br&gt;&lt;a href="termsofservice.php"&gt;terms of service&lt;/a&gt; &amp; &lt;a href="privacypolicy.php"&gt;privacy policy&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;td&gt; &lt;input type='button' name='submit' value='Register' class='registerbutton' onclick='ajaxregister()'&gt; &lt;div id="msg"&gt;&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;p&gt; </code></pre> <p></p> <p>There is the block of code for that part of the page. Any help would be greatly appreciated. Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload