Buttons in forms should declare a type
Rule
button-type· Links & buttons · impact minor · Static + live
Why it matters
A
How to fix
Add type="button" to buttons that should not submit; use type="submit" deliberately.
Example
<form><button>Toggle</button></form>
<form><button type="button">Toggle</button></form>
Example
<form id="checkout"></form><button form="checkout">Apply coupon</button>
<form id="checkout"></form><button form="checkout" type="button">Apply coupon</button>
The form attribute associates the button with the form even from outside it.
WCAG success criteria
3.2.2 On Input — Level A
Changing a control’s value (picking an option, typing) must not automatically trigger a change of context unless the user was warned beforehand.
Standards
This rule contributes to the following standards:
WCAG A EN 301 549 Best practice
| Standard | Criteria |
|---|---|
| EN 301 549 | 9.3.2.2 |