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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:09:00+00:00 2026-06-03T01:09:00+00:00

Background Using a jQuery modal dialog to present a form. The form has an

  • 0

Background

Using a jQuery modal dialog to present a form. The form has an autocomplete field. When the user selects an option from the autocomplete drop-down, the form loses focus. The jQuery dialog detects the ESC key, however ENTER key is never detected. Consider one of several forms (on the same page), having a variety of buttons:

Code

The source code to detect when the ENTER key is pressed:

  $(form).keyup(function( e ) {
    // Submit and close when Enter key pressed by triggering the accept button.
    //
    if( e.keyCode == $.ui.keyCode.ENTER ) {
      sequenceNumber = 0;
      $(this).parent().find( "#accept" ).trigger( 'click' );
    }
  });

This works as expected (the “accept” button is triggered and the server receives the values just fine) whenever any field of the form has focus.

Problem

When the dialog is shown but no fields have focus (e.g., the user clicks on “fish fillet” in the above image), then presses ENTER, the keyup event is never fired.

Question

How can you receive an ENTER event when the form does not have focus, but the jQuery dialog is still open? (In the same way that the jQuery dialog receives the ESC keypress to cancel and close the dialog.)

Thank you!

  • 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-03T01:09:01+00:00Added an answer on June 3, 2026 at 1:09 am

    I added the trigger on the body instead, then I check if the form is visible.

    $('body').keyup(function( e ) {
      if( e.keyCode == $.ui.keyCode.ENTER ) {
        if( $("#myform").is(":visible") ) {
          // Enter was pressed and form is visible
        }
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using the jquery ui modal dialog , the background shades grey (i assuming this
I have a JQuery UI dialog which is modal and has a black background
I was wondering how to implement a modal dialog with background overlay with jQuery
I'm using the jQuery UI dialog to present content in a new iFrame. Everything
I am using jQuery UI dialog for modal popups. I have some iframes in
I would like to pop a modal dialog using jquery ui where the overlay
My Needs: I am using a jquery modal dialog. I have some buttons on
I am using the Jquery UI, I am using a modal dialog which is
I have an ASP.NET website which uses the jQuery dialog to present the user
I am trying to achieve a modal overlay using jQuery. When a user clicks

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.