Disable Enter key in Forms

Discussion in 'Javascript' started by kevinold@gmail.com, Jan 21, 2005.

  1. Guest

    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
     
    , Jan 21, 2005
    #1
    1. Advertising

  2. Guest

    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.returnValue = false;
    event.preventDefault();
    }
    document.addEventListener("keypress", KeyPressEvent, true);


    that should work. track the event.target to get only the Enter on a
    textarea etc.
     
    , Jan 21, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?am9l?=
    Replies:
    0
    Views:
    752
    =?Utf-8?B?am9l?=
    Sep 28, 2006
  2. BrianDH

    Enter Key H*ll, control enter key submit button

    BrianDH, Jan 12, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    446
    Anders Matthiessen
    Jan 12, 2005
  3. M P
    Replies:
    1
    Views:
    556
  4. Matt
    Replies:
    1
    Views:
    565
    Michael Winter
    Mar 6, 2004
  5. HopfZ
    Replies:
    0
    Views:
    629
    HopfZ
    Aug 28, 2006
Loading...

Share This Page