首页 > 解决方案 > 表单按钮,无类型提交,提交表单

问题描述

我知道按钮上的 type="submit" 与输入相同。

这里的问题是:如果我有一个表单,没有任何提交按钮/输入,为什么会触发提交?

<form method="post" action="lf-p1-02a.html">
    <div class="d-flex justify-content-center flex-wrap buttonCheck multiButtonCheck">
        <button class="col-md-6 formButton bigButton">
            <span>Button 1</span>
        </button>
        <button class="col-md-6 formButton bigButton">
            <span>Button 2</span>
        </button>
        <button class="col-md-6 formButton bigButton">
            <span>Button 3</span>
        </button>
        <button class="col-md-6 formButton bigButton">
            <span>Button 4</span>
        </button>
    </div>
    <div class="d-flex justify-content-center formFooter">
        <button class="mainBtn">Continue</button>
    </div>
</form>

小提琴: http: //jsfiddle.net/36zsa1t8/(我知道没有任何样式)。

表单中的 Continue 按钮实际上是提交它,进入下一页。

代码上没有 JavaScript。

知道为什么会这样吗?

标签: htmlformsbuttonsubmit

解决方案


如此答案中所解释的,对于大多数浏览器,默认type值为。buttonsubmit


推荐阅读