stop [ENTER] from sending the form in NN/Firefox

Discussion in 'Javascript' started by Perttu Pulkkinen, Dec 2, 2004.

  1. I use hit two function to stop [ENTER] from sending the form. First one I
    use to move focus to the next desired field, second one to do nothing (when
    there is no desired field to go).

    Works in IE & Opera. How can I make these Netscape/Firefox-compatible (while
    still keep them working in IE/Opera)?

    function moveto(goal)
    {
    if(window.event && window.event.keyCode == 13)
    document.getElementById(goal).focus();
    return !(window.event && window.event.keyCode == 13);
    }

    function noenter()
    {
    return !(window.event && window.event.keyCode == 13);
    }

    --
    Perttu Pulkkinen
    www.risteys.net
    www.onnenliinat.com
    www.palvelukaupunki.fi
    Perttu Pulkkinen, Dec 2, 2004
    #1
    1. Advertising

  2. Perttu Pulkkinen wrote:
    > I use hit two function to stop [ENTER] from sending the form. First one I
    > use to move focus to the next desired field, second one to do nothing (when
    > there is no desired field to go).
    >
    > Works in IE & Opera. How can I make these Netscape/Firefox-compatible (while
    > still keep them working in IE/Opera)?
    >
    > function moveto(goal)
    > {
    > if(window.event && window.event.keyCode == 13)
    > document.getElementById(goal).focus();
    > return !(window.event && window.event.keyCode == 13);
    > }
    >
    > function noenter()
    > {
    > return !(window.event && window.event.keyCode == 13);
    > }
    >


    You need to pass the event object to your functions. window.event is a
    MS implementation. The event object will be passed as first argument to
    your event listener.

    Daniel
    Daniel Kirsch, Dec 2, 2004
    #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. Phil
    Replies:
    2
    Views:
    5,058
  2. Joshua Beall
    Replies:
    8
    Views:
    709
    Mark Parnell
    Apr 8, 2004
  3. =?Utf-8?B?am9l?=
    Replies:
    0
    Views:
    733
    =?Utf-8?B?am9l?=
    Sep 28, 2006
  4. Veronica Bourke

    C# .NET stop carriage return/enter key submitting the form

    Veronica Bourke, Feb 16, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    1,172
    Veronica Bourke
    Feb 16, 2005
  5. HopfZ
    Replies:
    0
    Views:
    562
    HopfZ
    Aug 28, 2006
Loading...

Share This Page