question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hidden form label: failure message not clearly identifying the problem

See original GitHub issue

axe 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:closed
  • Created 7 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
dylanbcommented, Oct 21, 2016

@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

1reaction
paulirishcommented, Oct 20, 2016

I think that it’d be slightly more clear if the error message indicated the label is hidden.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found