Good question. And the very same one that I had.
Here’s something new I learned:
If I have a button anywhere on the same page as my form, then that button decides that it wants to submit that form. Even if I have a submit button within the form.
The solution
Put type=”button” on the button. Then the browser knows that it’s a button:
<button type="button">Random button somewhere on the page</button>
You’d think that the fact that the element is called ‘button’ would be enough of a clue.
Thank you so much. Saved me from unnecessary worry. Such a simple thing and yet I didn’t know 😉
Haha yep, took me a while and a few cups of coffee to figure it out!
Wow… I owe you a beer sometime. That was suppppper annoying. What engineer thought to himself: “Hey lets make any random button element, connect to any random form element, and connect the submit action to it”