GX2017: form control has no label
An input, a select or a textarea has no label that the file shows.
Cause
A form control needs a name that a screen reader can say. A placeholder is not a label: it goes away when the user types.
Gx reads one file. A control has a label when one of these is true:
- It is inside a
labelelement. - It has an
id, and alabelof the file has the same value infor. - It has
aria-label,aria-labelledbyortitle.
Gx gives no finding for a control with a spread, and for an input with the type hidden, submit, button, reset or image.
Example
package search
<form action="/search">
<input type="search" name="q" placeholder="Search">
<button type="submit">Go</button>
</form>gx check reports:
search/Box.gx:4:3: GX2017: the <input> has no labelFix
- Put the control inside a label:
<label>Search <input type="search" name="q"></label>. - Or give it an
idand write<label for="...">with that id. - For a control with no visible label, write
aria-label="Search".