I’m using ASP.NET MVC 3 with unobstrusive ajax and I would like to prevent submit form by enter. I wrote the following code to do that
$(window).keypress(function (event) {
if (event.which == 13) {
event.preventDefault();
}
});
Unfortunately this event is not triggered on IE8. Is there any other options. (I’m using jQuery 1.6.4)
You should set focus on next element in DOM
Check the next element type, if the type is not a textarea (enters permitted), or button/submit (enter = click) then we just tab to the next thing.
example,