Zander
Zander

Reputation: 1076

Form button, without type submit, submits form

I know that type="submit" on a button, it's the same as an input.

The question here is: if I have a form, without any submit button/input, why is it triggering the 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>

Fiddle: http://jsfiddle.net/36zsa1t8/ (I know that there aren't any styles).

The Continue button from the form is actually submitting it, going to the next page.

No JavaScript on the code.

Any idea why is this happening?

Upvotes: 1

Views: 618

Answers (2)

Dhana
Dhana

Reputation: 1658

Change <Button> tag to <input type="button" value="Button">

<input type="button" class="col-md-6 formButton bigButton" value="Button">
            <span>Utilizo el listado mensual de<br> consumo o límite preconcedido</span>
        </input>

Updated JSFiddle

Upvotes: 1

Pourbahrami
Pourbahrami

Reputation: 320

As has been explained in this answer, For most browsers the default type of button is submit.

Upvotes: 2

Related Questions