Form Label Associated
Validates that every visible form input (text, email, password, select, textarea, etc.) has a programmatically associated label: <label for>, wrapping <label>, aria-labelledby, or aria-label.…
$ prime install @community/check-form-label-associated Projection
Always in _index.xml · the agent never has to ask for this.
FormLabelAssociated [check] v1.0.0
Validates that every visible form input (text, email, password, select, textarea, etc.) has a programmatically associated label:
Loaded when retrieval picks the atom as adjacent / supporting.
FormLabelAssociated [check] v1.0.0
Validates that every visible form input (text, email, password, select, textarea, etc.) has a programmatically associated label:
signature: (html: string, context?: object) -> CheckResult
predicate: // Every form input must have an associated label via one of:
// 1. label[for="${cssEscape(id)}"])
if labelFor && labelFor.textContent.trim() !== '': continue
// 2. Wrapping label
ancestor = inp.closest('label')
if ancestor && ancestor.textContent.trim().length > inp.value.length: continue
// 3. aria-labelledby
labelledby = inp.getAttribute('aria-labelledby')
if labelledby:
ids = labelledby.split(/\s+/)
if ids.every(i => document.getElementById(i)): continue
// 4. aria-label
ariaLabel = inp.getAttribute('aria-label')
if ariaLabel && ariaLabel.trim() !== '': continue
// No label found
placeholderOnly = inp.getAttribute('placeholder')
yield {
selector: cssPath(inp),
type: inp.type || inp.tagName.toLowerCase(),
fail: 'no-associated-label',
placeholderOnly: placeholderOnly !== null,
remedy: placeholderOnly ? 'placeholder is not a label — add
Validates
@community/rule-form-label-associated
Severity
critical
Failure Message Template
Form input '{selector}' (type={type}) has no associated label. {remedy}. Without a label, screen readers cannot announce the field's purpose.
Evaluation Method
automated
Tools
- axe-core
- @testing-library/dom
- lighthouse
False Positive Rate
low
Loaded when retrieval picks the atom as a focal / direct hit.
FormLabelAssociated [check] v1.0.0
Validates that every visible form input (text, email, password, select, textarea, etc.) has a programmatically associated label:
signature: (html: string, context?: object) -> CheckResult
predicate: // Every form input must have an associated label via one of:
// 1. label[for="${cssEscape(id)}"])
if labelFor && labelFor.textContent.trim() !== '': continue
// 2. Wrapping label
ancestor = inp.closest('label')
if ancestor && ancestor.textContent.trim().length > inp.value.length: continue
// 3. aria-labelledby
labelledby = inp.getAttribute('aria-labelledby')
if labelledby:
ids = labelledby.split(/\s+/)
if ids.every(i => document.getElementById(i)): continue
// 4. aria-label
ariaLabel = inp.getAttribute('aria-label')
if ariaLabel && ariaLabel.trim() !== '': continue
// No label found
placeholderOnly = inp.getAttribute('placeholder')
yield {
selector: cssPath(inp),
type: inp.type || inp.tagName.toLowerCase(),
fail: 'no-associated-label',
placeholderOnly: placeholderOnly !== null,
remedy: placeholderOnly ? 'placeholder is not a label — add
Validates
@community/rule-form-label-associated
Severity
critical
Failure Message Template
Form input '{selector}' (type={type}) has no associated label. {remedy}. Without a label, screen readers cannot announce the field's purpose.
Evaluation Method
automated
Tools
- axe-core
- @testing-library/dom
- lighthouse
False Positive Rate
low
Validates
@community/rule-form-label-associated
Severity
critical
Failure Message Template
Form input '{selector}' (type={type}) has no associated label. {remedy}. Without a label, screen readers cannot announce the field's purpose.
Evaluation Method
automated
Tools
- axe-core
- @testing-library/dom
- lighthouse
False Positive Rate
low
Source
prime-system/examples/frontend-design/primes/compiled/@community/check-form-label-associated/atom.yaml