This question should have been answered by jquery disable form submit on enter, but the answer to that question does not seem to work for me - when I press enter in an input text field three things occur:
- The field's change event is fired.
- The form is submitted.
- Finally the keyup event handler described in the aforementioned answer is fired.
Now, I can replace keyup with keydown and then submit is really not triggered. But the field's change event neither.
There are lots of links on the internet, but most are talking about complex scenarios, like disable if and when, etc...
All I want is always disable submit on enter, but nothing more.
I am using jquery 1.8.0
Thanks.
EDIT
I want to clarify. I do want the submit to occur when the user clicks on the submit input button. I just do not want it to happen on enter.
<form id="invoiceForm">
...
<input type="submit"/>
</form>
EDIT2
http://jsfiddle.net/mark69_fnd/akZG4/ - If the submit is triggered one should see the message
{"error": "Please use POST request"}
I do not want to see this message on enter. Only when the submit is actually clicked.
EDIT3
I changed the fiddle to actually submit for a blank page and alert on submit.
EDIT4
I want to prevent the default action of submitting the form on hitting the enter key inside a text input field. But I do want to preserve the behaviour natural for a text input - triggering the change event.