Disable Enter key in Forms

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kevinold@gmail.com

    Disable Enter key in Forms

    Hello everyone,

    I've searched google and found several scripts that will "Disable" the
    enter key in forms, but none of them seem to work in Firefox 1.0.

    One such is here http://www.phpfreaks.com/quickcode/code/162.php

    Also, on another note, where did the Netscape Javascript reference site
    (also known as DevEdge) go? Anyone aware of where other Javascript
    references are?

    Any help is appreciated!

    Kevin

  • goulart@gmail.com

    #2
    Re: Disable Enter key in Forms

    You should try capturing the onkeypress event at the document level,
    where it can be blocked.

    KeyPressEvent = function (event) {
    if (event.which != 13) return true;

    event.returnVal ue = false;
    event.preventDe fault();
    }
    document.addEve ntListener("key press", KeyPressEvent, true);


    that should work. track the event.target to get only the Enter on a
    textarea etc.

    Comment

    Working...