New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check for submit buttons outside of form element, associated using form attribute #226
Comments
I think this would be easy enough by adding another test after the existing checks. Pseudocode:
This is just a brain-dump for now. I might take a crack at a PR myself, but I'll leave this here in case someone else wants to try it. |
Thanks @fuzzbomb. I'm going to mark this as an enhancement since the project pre-dates the HTML 5.2 spec. It doesn't look difficult to add, but we've got a body of work pending for WCAG 2.1 support so if we don't have a pull request it'll likely be rolled into that. |
I got this working. First it looks for buttons which have form attributes, then does a couple more checks on each one to confirm it's a submit button for the form in question. |
Hi @fuzzbomb, thanks for submitting the pull request. It works great, I've merged it in master for the next release. |
That's great, thanks. I got involved in this by answering an accessibility question on StackOverflow - submit button in a different component creating Accessibility issue. It was a fun rabbit hole to go down :-) |
(Expanding on of an issue originally filed to pa11y: pa11y/pa11y#419)
HTML5 introduced the
form
attribute to buttons (and other form controls) so they could be associated with a<form>
, and trigger form submission, without actually having to be nested inside the<form>
element itself. See Association of controls and forms in the HTML5 recommendation.When a
<button>
has aform
attribute, but is outside the<form>
element itself, you get the error about a missing submit button:The following code only checks for submit buttons that are inside the form element. Note that querySelectorAll() is called on the form element, so it only looks for descendants. (In
Standards/WCAG2AAA/Sniffs/Principle3/Guideline3_2/3_2_2.js
).I propose this test can be extended to look for submit buttons outside the form element, which are associated correctly using a
form
attribute.The text was updated successfully, but these errors were encountered: