2

Hey. I've got an HTML textbox, but when I press enter, it causes a postback. I'd rather it either do nothing or 'click' a hyperlink anchor. How do I stop the textbox from causing a postback when the enter key is pressed? Tthanks

I have:

<input id="textbox" type="text" /> 
<a href="#">Locate</a>
Gert Grenander
  • 16,866
  • 6
  • 40
  • 43
Skoder
  • 3,983
  • 11
  • 46
  • 73

1 Answers1

3

Create a javascript onSubmit handler that returns false. E.g.

<form name="form1" onSubmit="return false;">
    <input type="text" value="Parnsip, turnip" />
</form>
fmark
  • 57,259
  • 27
  • 100
  • 107