How do I stop enter key from triggering a non-submit button?
I have a form with a bunch of selects and a single text input. Form data is sent via $.post whenever the inputs are changed, so a submit button isn't needed. The form does contain one regular button (using the button tag, not the input tag). The button shows a jQuery UI dialog when clicked.
If you press the enter key in the text field, the browser submits the form but it also acts like you clicked the button (the dialog appears). That makes no sense to me. Why is this happening and how can I stop it? I've already tried adding a few things to the form's submit handler, but they don't make a difference.
- $('#filters').submit(function(event) {
- event.preventDefault();
- event.stopPropagation();
- clearTimeout(window.refresh_timer);
- update_list();
- return false;
- });