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!