0

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?

Community
  • 1
  • 1
Varada
  • 14,661
  • 13
  • 46
  • 67

3 Answers3

4

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.

Joe
  • 3,002
  • 6
  • 43
  • 62
Paul Rosania
  • 9,573
  • 2
  • 19
  • 18
1

See this: Bind textbox to 'enter' key and form.submit() method.

Community
  • 1
  • 1
c-smile
  • 25,702
  • 7
  • 55
  • 82
0

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.

Krishna
  • 1,454
  • 5
  • 16
  • 31