开发者

Stop textbox causing postback

开发者 https://www.devze.com 2023-01-26 00:45 出处:网络
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 t

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>


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

<form name="form1" onSubmit="return false;">
    <input type="text" value="Parnsip, turnip" />
</form>
0

精彩评论

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