I've blocked Enter (return) key, actually, transformed it in Tab key. So when pressed inside input text fields it acts as Tab key. This is good, but I need it to trigger the submit button when pressed in the last field, below is the code for the Enter key mutation:
$('input').keydown(function(event) {
if(event.which == 13) {
event.preventDefault();
$(this).nextAll('input:first').focus();
}
});
And the form code is a sequence of input type="text" and a button type="submit" at the end [Edited] Actually the code is this one, taken from jquery: Enter to Tab trigger in specific parts. But I don't know why it was working yesterday today is not working:
$(':text').keydown(function(e) {
if(e.keyCode == 13 && $(this).attr('type') != 'submit') {
e.preventDefault();
$(this).nextAll('input:first').focus();
}
});
If you give your last input the class of last then simply modify your code to something like
$('input').keydown(function(event) {
if(!$(this).hasClass("last")){
if(event.which == 13) {
event.preventDefault();
$(this).nextAll('input:first').focus();
}
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With