0

I had a button inside a form, with a number of inputs as well. The button was NOT designed to submit the form, but rather to activate some javascript. However, every time I clicked it while I was debugging, my console said that it was submitting. I moved the button out of the form, and the problem was solved. However, I am curious as to why the button automatically acted as a submit button. I did not give it any attributes except a class, and text between the open and close tags. There was no action, and the onClick called a separate JS function.Does anyone know why a button inside a form is automatically treated as a submit button?

  • 8
    By default, [*button* elements](http://www.w3.org/html/wg/drafts/html/master/semantics.html#the-button-element) in forms are submit buttons. Change the type to button, or use an input type button. – RobG Jul 24 '15 at 23:42
  • 1
    `` – Ry- Jul 24 '15 at 23:43

0 Answers0