/    Sign up×
Community /Pin to ProfileBookmark

how to invoking the button through keyboard enter after entering the password ?

Hi All,

I am in the process of building a web application. In the initial login page , I am allowing the user to type the user name and the password.

As per my requirement I need to submit the form by pressing enter (not by clicking thru mouse).

I am able to set the focus on button through “document.getElementById(“button”).focus()” on page load. But when i try entering the password the focus changes from button to the text box and as a result the enter key is not redirecting the page.

My question is, IS there any way by which we can set the focus to the button after entering the password , so that my keyboard enter will trigger the form submit?

Please help me in this . Its a urgent requirement

Thanks for your help in advance
Arun Kumar

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@toicontienMar 17.2008 — In order for the ENTER key to submit the form, you need to fulfill three requirements:

  • 1. A text box (you have this)


  • 2. A submit button. I'm talking about an INPUT whose type is "submit" or "image", or a BUTTON element whose type is "submit" or "image".


  • 3. A FORM tag whose action attribute points to a server side script.


  • Basically, you need a real HTML form, not some JavaScript hacked version. Turn JavaScript off. If your form does not function properly, you have not fulfilled all three of the requirements listed above. Can you post the HTML for your FORM?
    ×

    Success!

    Help @camarun20 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.17,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...