Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
Bind enter key to different submit input

I am developing a webpage with a form with several <input type="submit"> and one <input type="password">. It is a multistep form managed by ajax callbacks.

The reason I am using more than one Submit per form is because Drupal Ajax callbacks are called by them. My problem and question is the following:

Is there any way to bind "enter" to a certain submit?

I have tried this piece of code (using jQuery):

$('#myInput').on('keyup', function(event) {
    // I have tried event.preventDefault(); here
    if (event.keyCode == 13) { // 13 stands for Enter key
        // And here
        $('#desiredSubmitInput').click();
    }
});

But I think there is some kind of async because "Enter" behavior is happening before the click and therefore submits a random submit (I don't even know if it is random or taking first/last submit, not the desired one).

I have even tried to preventDefault the keyUp event but it neither works.

Thank you!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!