Defining the type in buttons is important

This is a cool form

These buttons are inside the form.

When the form data is submitted, the background colour changes.

These buttons are outside the form

For comparison, these buttons are outside the form. As such, they won't trigger the submit event. They will do nothing.

The form above executes a JavaScript function whenever the submit event is fired. The function changes the background colour of this page. The form contains 4 buttons, each with a different type attribute value: type="submit", type="button", type="reset" and no type attribute. Click each button and notice which ones trigger the onsubmit event.