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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:34:11+00:00 2026-05-26T13:34:11+00:00

Hi i was im trying to make a jquery ajax submit form, and im

  • 0

Hi i was im trying to make a jquery ajax submit form, and im currently trying to make restrictions for submiting a form.
i want the user to press enter to submit a form and not press on a submit button,
but only when the user is focusing on a textarea/input field it will submit when he/she presses enter!

i have attempted to make my own code and edit in it to see what works,
and i have figured this code out, but it doesnt work quite well 🙁

$('.addformtextarea').focus(function() {

$(document).keyup(function(e){
    switch (e.keyCode) {
        case 13: //enter
        //code to be 
        break;
    }
});

.addformtextarea is the textarea to be focused on.

and does return false; behave the same as break; ? because i have a return false; right before break;

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-26T13:34:11+00:00Added an answer on May 26, 2026 at 1:34 pm

    Try this:

    $('.addformtextarea').keyup(function(e){
        switch (e.keyCode) {
            case 13: //enter
            //code to be 
            return false;
        }
    });
    

    You don’t need to worry about focus, because the keyup would only fire if the input has focus.

    The break only breaks out of the switch, you need return false to prevent the automatic submit, if you are doing it with the code.

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

Sidebar

Related Questions

I'm trying to make a jquery login system, but when I submit the form,
I am trying to make a Ajax form Submission in Jquery. The form itself
I trying to make my first AJAX with JSON call using jQuery and CodeIgniter.
I am trying to make two ajax requests in parallel using jQuery like this:
i am trying to make a ajax call by making use of jquery UI
I'm trying to to make AJAX call with the jQuery library using the $.ajax()
I'm trying to implement authentication using jquery to make an ajax request to a
I am trying to use jQuery to make a synchronous AJAX post to a
I am trying to use the jQuery $.post method to submit an ajax request
I'm trying to make jQuery's ajax calls always return as if they succeeded, e.g.

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.