Skip to Content
author's profile photo Former Member
Former Member

Form submission on enter key

This should be simple for somebody.

How do you setup a jsp form and let the enter key perform the same action anywhere on the form as if a submit button was pressed.

// i.e If (keypressed = enter) call server event

Add comment
10|10000 characters needed characters exceeded

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jul 29, 2004 at 02:52 PM

    I'm afraid I've not got a code sample with me but I've done this before using Javascript Events. You can have a piece of code that runs when the user presses any key ( onkeydown in the body tag etc)

    It is possible to grab the event and get the keypress ('13' for enter). Google for javascript event handling and you should find out more.

    As i remember, you have to set the event to false after you have hijacked it otherwise it will go and do the event anyway.

    R

    Add comment
    10|10000 characters needed characters exceeded