Hidden form label: failure message not clearly identifying the problem
See original GitHub issueaxe incorrectly reports that an element within the following HTML does not have a label (when embedded within a larger HTML file):
<form class="search" action="/" data-gp-element="search">
<label class="gp-offline-disable" for="s">Search</label>
<input class="gp-offline-disable" type="search" name="s" id="s" placeholder="Search" value="">
<button type="submit">Go</button>
</form>
The input is correctly detected if the entire HTML file is as above; it’s only a problem if embedded within a larger file.
To reproduce, first load https://cdn.rawgit.com/ithinkihaveacat/8577d6d00eb08f48b4a6e3fd015c379d/raw/f943193a01bff03ea7df37b9bf4ef206d9f2486c/index.html, then paste the following in the JS console to run the accessibility tests:
function loadScript(src) {
return new Promise(resolve => {
const e = document.createElement("script");
e.src = src;
e.onload = resolve;
document.head.appendChild(e);
});
}
loadScript("https://unpkg.com/axe-core/axe.min.js").then(() => {;
axe.a11yCheck(document, r => console.log(r.violations[2]));
});
Actual output:
A Form elements must have labels
error on the element <input class="gp-offline-disable" type="search" name="s" id="s" placeholder="Search" value="">
.
Expected output:
No error report (on this element; there are other accessibility errors in the HTML).
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (9 by maintainers)
Top Results From Across the Web
Empty or Missing Form Label - Equalize Digital
If you see a missing or empty form label error in Accessibility Checker, the best course of action is to open your form...
Read more >Understanding Success Criterion 3.3.2 - W3C
The intent of this success criterion is to have content authors place instructions or labels that identify the controls in a form so...
Read more >Provide helpful error messages | Digital Accessibility
Make it easy to locate the problem: Programmatically associate each error message with its corresponding form control using the aria-describedby attribute.
Read more >Troubleshoot form issues in model-driven apps - Microsoft Learn
Because they introduce a race condition, the issue only occurs when the custom script executes before the form is fully ready to be...
Read more >aria-errormessage - Accessibility - MDN Web Docs - Mozilla
The aria-errormessage attribute on an object identifies the element that provides an error message for that object.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@paulirish that is a valid point, I think we could improve this.
Note to implementor: we would probably want to create a separate “fail” check that looks for a hidden explicit label and flags this while simultaneously changing the explicit label check to allow hidden labels to pass
I think that it’d be slightly more clear if the error message indicated the label is hidden.