How can I prevent the Enter button from starting its default behavior in Firefox 12?

I have a form embedded in ASP.NET. The first control allows the user to select a person from the autocomplete list. When the user is clicked, he will refresh the page and duplicate any information obtained using this first control. I am trying to remove the ability to enter a key from a page refresh. This code works in Chrome and IE7 / 8/9 (don't care about 6). All I NEED is to return false for it to work in all browsers that we support besides Firefox..click () is a bonus to add a bit of usability to the key (so that it activates the controls and selects the checkbox or unchecked and etc.).

None of this works in Firefox 12. A click occurs (proof that the code is reached when I want it), but the page refreshes every time.

FocusNextInputfield () was one of the suggestions on a similar issue and did not do anything that I wanted. He may have done what he intended, but I cannot say because the page has been updated.

I found preventDefault () and stopPropagation () from another similar question myself, and it did nothing in FF.

I even tried to get back to the truth.

   $(document).keydown(function (event) {
   //handles what happens when the user hits enter
       if (document.activeElement.nodeName !== 'TEXTAREA') {
           if (event.keyCode === 13 || event.which === 13) {
                $(document.activeElement).click();
               // $(document.activeElement).focusNextInputField();
                event.preventDefault();
                event.stopPropagation();
                return false;
           }
       }
    }); 

I'm just looking for any suggestions or news for any reason, none of this has any effect in FireFox 12? And I know that the code has been reached, and everything works correctly without errors and even with all the redundant code that it still works in Chrome and IE 7/8/9, as I said.

, , .

+3
1

, jQuery, , , - Default submit.

$j("#form-id").submit(function(e) {
    e.preventDefault();
    ...
});

:

$j("#form-id").submit(false);
+2

All Articles