How to make the enter key not give submit on a form?
Example: in an input pressing enter nothing happens.
Today, if you press enter , the browser gives submit , and you clicked the submit button.
How to make the enter key not give submit on a form?
Example: in an input pressing enter nothing happens.
Today, if you press enter , the browser gives submit , and you clicked the submit button.
You can replace the handler with the default behavior:
$(document).ready(function() {
$(window).keydown(function(event){
if(event.keyCode == 13) {
event.preventDefault();
return false;
}
});
});
Or, in the Form tag:
<form onsubmit="return false;">
It also gives:
$('#form').bind('submit', false);
$('button#submit').click(function()
{
$('#form').submit();
});
This will cause the form to be sent only when you click the submit button.