Submit a textbox by pressing enter key [duplicate]
Possible Duplicate:
Bind textbox to 'enter' key
I have a search text box. I would like to get it submitted while pressing the enter key (when that text box is focused only). I am not using any submit button. Can this be accomplished using javascript?
As long as the <input>
tag is inside a <form>
tag, the form will be submitted automatically when the user presses the Enter key from within the text field. This is default behavior on all web browsers.
See this: Bind textbox to 'enter' key
and form.submit()
method.
Yes, we can implement that using javascript. Write a javascript funciton and call it when you click the button. Using form.yourTextBoxId you can get the value from the text box.
精彩评论