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

Submit a form using keyboard Return/Enter

Hi,

I am looking for an equivalent of Submit button in HTMLB.

I need to submit the form when the user hits on the Return/ Enter from Keyboard. I am using HTMLB buttons on my JSP.

Does anyone know how to do this?

Thanks

Lakshmi

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jun 03, 2004 at 05:48 PM

    Try the following :

    When you create the input field(s) add a javascript event listener

    InputField inf2 = new InputField("myInput");

    // Enable JavaScript object generation for access in JavaScript

    inf2.setJsObjectNeeded(true);

    inf2.setClientEvent(EventTrigger.ON_KEYUP, "checkForSubmit(this,event)");

    (I am not sure if the parameters for the javascript method works)

    Then add a javascript method :

    function submitenter(myfield,e)

    {

    var keycode;

    if (window.event) keycode = window.event.keyCode;

    else if (e) keycode = e.which;

    else return true;

    if (keycode == 13)

    {

    //add code to submit the form

    //left as an exercise to the user

    return false;

    }

    else

    return true;

    }

    This should at least get you started

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.