blob: cb0068ab095417511838e6296d068079c0c773e8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
exports.name = 'All input fields have exactly one label.';
exports.description = '<p>Screen readers rely on HTML attributes to identify the purpose '
+ "of form widgets on-screen. These tools use label tags with 'for' "
+ 'attributes that specify the id of the form element they pertain to. '
+ 'Some of the components of this web page do not have those labels.</p>';
exports.rule = function(report) {
$5(':input').each(
function(i, elt) {
if (elt.id) {
var $label = $5("label[for='" + elt.id + "']");
if (1 < $label.size()) {
report.error('Form element has too many labels', elt);
}
if (0 == $label.size()) {
report.error('Form element has no label', elt);
}
}
});
}
|