RGAA 3.0 - Rule 11.1.2

Summary

This test consists in checking the presence and the unicity of the "id" attribute of each form field associated with a <label> tag. We assume here that a form field is associated with a <label> tag when its "id" attribute corresponds to the "for" attribute of any <label> tag.

Business description

Criterion

11.1

Test

11.1.2

Description

Does each form field that is associated with a label (label tag), meet the following conditions? The form field has an id attribute

Level

A

Technical description

Scope

Page

Decision level

Decidable

Algorithm

Selection

Set1 (input form fields)

All the <input> tags within a <form> tag with a "type" attribute equals to:

  • “text”
  • or “password”
  • or “checkbox”
  • or “radio”
  • or “file”
  • or “search”
  • or “tel”
  • or “email”
  • or “number”
  • or “url”
  • or “date”
  • or “range”
  • or “color”
  • or “time”

AND all the <textarea>, <select>, <datalist>, <keygen> tags AND for all of them no "aria-label", "aria-labelledby" or "title" attribute.

Set2

All the <label> tags within a <form> tag

Set3

All the element of Set1 with no <label> tag as parent.

Set4

All the element of Set2 with an <input> child with an "id" attribute.

Process

Tests

Test1

For each element of Set1, test if the node contains a not empty "id" attribute.

For each occurence of false-result of Test1, raise a MessageA.

Test2

For each element of Set1 with an "id" attribute, test that this id is unique on the page.

For each occurence of false-result of Test2, raise a MessageB.

Test3

For each element of Set2, test if this element has a not empty "for" attribute.

For each occurence of false-result of Test3, raise a MessageC.

Test4

For each element in Set3, test if the "id" attribute is equals to the "for" attribute of a <label> in the same .

For each occurence of false-result of Test4, raise a MessageD.

Test5

For each element in Set4, test if the "for" attribute is equals to the “id” attribute of the <input> in the same .

For each occurence of false-result of Test5, raison a MessageE.

Messages

MessageA : Id attribute missing
  • code :IdMissing
  • status: Failed
  • parameter : tag name
  • present in source : yes
MessageB : Id Not Unique
  • code :IdNotUnique
  • status: Failed
  • parameter : tag name
  • present in source : yes
MessageC : For attribute Missing
  • code :ForMissing
  • status: Failed
  • parameter : tag name
  • present in source : yes
MessageD : Input Not linked To Label
  • code :InvalidInput
  • status: Failed
  • parameter : tag name
  • present in source : yes
MessageE : Label Not linked To Input Child
  • code :InvalidLabel
  • status: Failed
  • parameter : tag name
  • present in source : yes

Analysis

Not Applicable

There is no input form tag on the page (Set1 is empty).

Failed

At least one input element on the page is not well linked with a label. (Test1 OR Test2 OR Test3 OR Test4 OR Test5 return false for at least one element).

Passed

All input on the page are well associated with a label. (Test1 AND Test2 AND Test3 AND Test4 AND Test5 return true for all the elements).

TestCases

TestCases files for rule 11.1.2