I have a form with a text input.
I managed to prevent ENTER from submitting the form by doing this:
jQuery("#inputTags").keydown(function(event) {
if (event.keyCode == '13') {
event.preventDefault();
tagManagerCreate(true);
return false;
}
});
tagManagerCreate() does some stuff. Sometimes, this function triggers a javascript “alert”.
For some reason when that happens, the form still gets submitted!
I think you should use
.keypressinstead of.keydownhttp://api.jquery.com/keypress/
http://api.jquery.com/keydown/
and what the tagManagerCreate(true); do?