Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6708297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:44:32+00:00 2026-05-26T07:44:32+00:00

I am using a button to submit a form, not a submit button. However,

  • 0

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. http://www.pearlsquirrel.com/register.php

Here is the code to register.php

<div id="centered3">
<h1><div align='center' style="color:white;">Join PearlSquirrel</align></h1>
<h4><div id='response'></div></h4>
<script language='javascript' type='text/javascript'>
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 + '&password=' + password +     '&repeatpassword=' + repeatpassword;
ajaxRequest.open('GET', 'ajaxregister.php' + queryString, true);
ajaxRequest.send(null); 

}
</script>
<form method='GET'>
<table>

        <tr>

            <td>
                Choose a username:

            </td>

            <td>
                <script type="text/javascript"     src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
<script>
$(document).ready(function(){
$('#username').keyup(username_check);
});

function username_check(){  
var username = $('#username').val();
if(username == "" || username.length < 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();
}

}
});
}

}

</script>
</head>
<script>
function nospaces(evt)
{
 var charCode = (evt.which) ? evt.which : event.keyCode
 if (charCode == 32)
    return false;
 return true;
}
</script><body>

<input name="username" id="username" type="text" style="height:30px; width:212px;"     value='<?php echo $username; ?>' onkeypress="return nospaces(event)"/>
<img id="tick" src="tick.png" width="16" height="16"/>
<img id="cross" src="cross.png" width="16" height="16"/>

</body>
</html>
            </td>

        </tr>

        <tr>

            <td>
                Choose a password:

            </td>

            <td>
                <input type='password' name='password' id='password' style="height:   30px; width:220px;" > 
            </td>

        </tr>

        <tr>

            <td>
                Repeat your password:

            </td>

            <td>
                <input type='password' name='repeatpassword' id='repeatpassword' style="height: 30px; width:220px;" > 
            </td>

        </tr>
        <tr>

            <td>

            </td>

             <td>
                By registering, you agree to the<br><a href="termsofservice.php">terms   of service</a> & <a href="privacypolicy.php">privacy policy</a>
            </td>

        </tr>
        <tr>

            <td>

            </td>

            <td>

<input type='button' name='submit' value='Register' class='registerbutton'    onclick='ajaxregister()'>
<div id="msg"></div> 

            </td>

        </tr>
</table>

    <p>

There is the block of code for that part of the page. Any help would be greatly appreciated. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:44:33+00:00Added an answer on May 26, 2026 at 7:44 am

    You gotta add onKeyPress handlers for input fields and check the keyCode: if it is 13 (Enter), execute Submit button handler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First time using Asp.net-mvc and originally followed the NerdDinner tutorial. My form submit button
Using the AngularJS framework, how do I have the Submit button both update the
Actually I created a button using the cobogw widget library. But the button does
I want to use a form that has two submit buttons. Each button calls
I have two buttons inside a form call: <% using (Html.BeginForm()) {%> <input type=submit
I have a very simple form with a single autocomplete widget. No submit button.
Problem After downloading a CSV once, the form does not send a request on
I'm using GWT 2.4. I have a form in which I create a submit
I've started using the button element to submit my forms <button type=submit>Send</button> I know
I've deconstructed a standard WPF button using Blend and have managed to create a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.