-1

I have a form below with a button, but the button is not a submit one. Why the form is still submitted when clicking the button?

<form>
  <div class="field">
    <div class="control">
      <input class="input is-large" type="email" placeholder="Your Email">
    </div>
  </div>
  
  <div class="field">
    <div class="control">
      <input class="input is-large" type="password" placeholder="Your Password">
    </div>
  </div>
  <button class="button is-block is-info is-large is-fullwidth">
    Login <i class="fa fa-sign-in" aria-hidden="true"></i>
  </button>
</form>
Henry
  • 1,077
  • 1
  • 16
  • 41
  • [The HTML5 placeholder attribute is not a substitute for the label element](http://www.456bereastreet.com/archive/201204/the_html5_placeholder_attribute_is_not_a_substitute_for_the_label_element/) – Quentin Jun 20 '21 at 13:27

2 Answers2

2

For most browsers the default type of button is submit . This attribute declares the type of the button.if you add type attribute like this <button type="button"> then submit not work.

Fuad Saneen
  • 354
  • 1
  • 10
0

You need to add the type attribute as button then the button won't submit the form. Ex:

<button type="button">Click</button>

Ref: https://www.w3schools.com/tags/att_button_type.asp

Pablo
  • 5,897
  • 7
  • 34
  • 51