I've found several jQuery syntaxes for nullifying the enter on a form.
First one:
$("form input[@type=text]").bind("keypress", function(e) {
var code=e.charCode || e.keyCode;
return (code==13)?false:true;
});
Second one:
$("form").bind("keypress", function(e) {
if (e.keyCode == 13) return false;
});
My version:
$('form').keypress(function(e) {
if (e.which == 13) return false;
});
My question is:
Q: Is my version ok to use, or is there a best practice for defeating the enter key from doing a form submit?