开发者

Form submits in FireFox when any button on page is clicked

开发者 https://www.devze.com 2022-12-24 01:46 出处:网络
First time using Asp.net-mvc and originall开发者_Python百科y followed the NerdDinner tutorial.My form submit button looks like this:

First time using Asp.net-mvc and originall开发者_Python百科y followed the NerdDinner tutorial. My form submit button looks like this:

<p>
    <input type="submit" value="Save" />
</p>

I've now added another button to the page with jQuery code attached. It works in IE, but when I test in FireFox the form submits. I tried adding another button, this time with no attached jQuery code and the same thing happens. When the button is clicked, the form submits.

<button id="random-button">Do Nothing</button>

Why does the standard button element submit the form in Firefox?


I recall that Firefox defaults a <button> to a submit button. If you use

 <button type="button" id="random-button">Do Nothing</button>

it should solve your problems.

0

精彩评论

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