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 9228733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:23:53+00:00 2026-06-18T05:23:53+00:00

I got a login form which has a button that is click to call

  • 0

I got a login form which has a button that is click to call ajax request, the request is trigger only if i mouse clicked on the button instead of press the enter key,

<form id="signin_form">
    Email: <input type="text" id="email" name="email">
    Password: <input type="password" id="password" name="password">
    <input type="button" id="btn_signin" value="Sign In">
</form>

I found a working sample from here (thanks to Stackoverflow) by how to make it on keypress, below is almost the same reaction, can below scripts merge together in order to make the scripts clean?

$("#password").keypress(function(event) {
    if (event.which == 13) {
        event.preventDefault();

        var parameters = $('#signin_form').serialize();

        $.ajax({
            url: baseurl + 'loginRequest',
            type: 'POST',
            data: parameters,
            dataType: 'json',
            success: function(output_str){
                if(output_str == "success"){

                    window.location.replace(window.location);
                }else{
                    $('#result').html(output_str);
                }
            }
        });
    }
});

// login request
$('#btn_signin').click(function(){
    var parameters = $('#signin_form').serialize();

    $.ajax({
        url: baseurl + '/login',
        type: 'POST',
        data: parameters,
        dataType: 'json',
        success: function(output_str){
            if(output_str == "success"){

                window.location.replace(window.location);
            }else{
                $('#result').html(output_str);
            }
        }
    });
});

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-06-18T05:23:54+00:00Added an answer on June 18, 2026 at 5:23 am
    $("#password").keypress(function(event) {
        if (event.which == 13) {
            event.preventDefault();
            $('#btn_signin').click();
        }
    });
    
    // login request
    $('#btn_signin').click(function(){
        var parameters = $('#signin_form').serialize();
    
        $.ajax({
            url: baseurl + '/login',
            type: 'POST',
            data: parameters,
            dataType: 'json',
            success: function(output_str){
                if(output_str == "success"){
    
                    window.location.replace(window.location);
                }else{
                    $('#result').html(output_str);
                }
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I've got a save button on my form, which has a callback function
I've got a log in page, which upon submission of the login form, displays
i've got a site, which has a login system. here's my scenario: user is
I have Ajax login form, which is checking whether given credentials are correct and
I've got a user log in form which sets a cookie and enables members
I've got a standard login form submitting data to a Codeigniter function to do
I got this from for a login form tutorial: function sanitize($securitystring) { $securitystring =
I got to thinking that maybe my login system isn't as secure as I
I've got a script which launch this MySQL command : mysqldump -u login -ppass
I've got a WCF service that offers a Login method. A client is required

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.