开发者

Submit a textbox by pressing enter key [duplicate]

This question already has answers here: Closed 10 years ago. 开发者_如何学Python

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜