Reputation: 1162
In our organization we're still using the IE8 standard. On one of our web-based applications, we noticed we could not submit forms via the Enter
key. After searching the web, I stumbled across this answer: https://stackoverflow.com/a/4629047/731052
While the jQuery solution does work, our users still get a "ding" whenever they press the Enter
key. Is there a way to prevent this from happening? When I'm on sites like Google, I don't get any "dings" when I press enter. Thanks!
Upvotes: 3
Views: 4331
Reputation: 9570
use this
if (e.which == '13') {
e.preventDefault();
//then put your code
}
Assuming you were using the code from the question that you have a link to
jQuery.fn.handle_enter_keypress = function() {
if ($.browser.msie){
$(this).find('input').keypress(function(e){
// If the key pressed was enter
if (e.which == '13') {
$(this).closest('form')
.find('button[type=submit],input[type=submit]')
.filter(':first').click();
}
});
}
}
Upvotes: 11