Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

105
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda