Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda