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
  • 16,026
  • 13
  • 48
  • 69

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.

Sastrija
  • 3,284
  • 6
  • 47
  • 64
Paul Rosania
  • 9,823
  • 2
  • 20
  • 18
1

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

Community
  • 1
  • 1
c-smile
  • 26,734
  • 7
  • 59
  • 86
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