user426795
user426795

Reputation: 11663

my enter key is not working for form?

I have a form which has one field username. If some one submit the button "enter" the next field pop up. I have done using the jquery . And it after entering the password in that field when i click the "login" button (input type of button is submit in both case) request goes to the server. Every thing working fine for all browsers except firefox. When someone click the login button it works fine but when when i want to submit the form by hitting the enter key nothing happens. Each time for submit in firefox i have to use mouse. So, what can be the problem. I am not putting the code but it is simple form.

Upvotes: 2

Views: 2769

Answers (3)

brettish
brettish

Reputation: 2638

The documentation for jQuery says:

Depending on the browser, the Enter key may only cause a form submission if the form has exactly one text field, or only when there is a submit button present

If those conditions are not met, you may need to assign a key listener and listen for the enter key. Also, I wouldn't be surprised if the "submit button" has to be an input of type submit, not a button... but I don't feel like testing it to confirm :-)

Upvotes: 2

Skorpioh
Skorpioh

Reputation: 1355

I may be wrong, but the solution to your issue may be to set the focus on the button:

document.getElementById('buttonID').focus()

Hope this helps.

Upvotes: 0

Dutchie432
Dutchie432

Reputation: 29160

Are your next buttons actually <input type="submit"> buttons, or just regular <button></button> buttons?

As per my recent question, the only way to process a form by pressing enter is to have 1) a sumbit button or 2) an onkeypress (or oninput) event in the input fields to listen for the enter key.

Upvotes: 1

Related Questions