Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I prevent the Enter button from running its default behavior in Firefox 12?
    primarykey
    data
    text
    <p>I have a form built in ASP.NET. The first control allows the user to choose a person from an auto-complete list. When the user pressed enter it would refresh the page and duplicate any information acquired through this first control. I am trying to remove the capability of the enter key from refreshing the page. This code all works in Chrome and IE7/8/9 (Don't care about 6). All I NEED is the return false for it to work in all browsers we support besides Firefox. The .click() is a bonus to add a bit of usability back to the key (so that it will activate the controls and check or uncheck check boxes, etc.)</p> <p>None of this works in Firefox 12. The click occurs (proof that the code is reached when I want it) but the page refreshes every single time. </p> <p>The focusNextInputfield() was one of the suggestions from a similar question and didn't do anything I wanted. It may have done what it was intended for but I can't tell because the page refreshed. </p> <p>I found preventDefault() and stopPropagation() from yet another similar question on my own and it did nothing in FF. </p> <p>I have even tried returning true for the heck of it. </p> <pre><code> $(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; } } }); </code></pre> <p>I am just looking for any suggestions or news on any reason none of this has any effect in FireFox 12? And I know that the code is reached and it all runs properly without error and even with all the excess code it still runs properly in Chrome and IE 7/8/9 as I said.</p> <p>And through an earlier iteration I tried forcing the submit button to be clicked but it still refreshed anyway and validated and was overall a bad user experience. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload