blob: e93c3703334841c728a389e59cc262242ceefca6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
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() {
var that = this;
fiveui.query(':input').each(
function(i, elt) {
if (elt.id) {
var $label = fiveui.query("label[for='" + elt.id + "']");
if (1 < $label.size()) {
that.report('Form element has too many labels', elt);
}
if (0 == $label.size()) {
that.report('Form element has no label', elt);
}
}
});
}
|