What fresh hell is THIS now? - Patrick Lauke
<fieldset>
and using a <legend>
) should each checkbox get the required
attribute?
getElementById
I believe (based on Chromium code at least), which says:
undefined
, but undefined in the CS sense
getElementById()
[chris__pearce] Sorry about the delay, on the required checkbox question I posted yesterday, StommePoes mentioned this:
If every input that is a checkbox is required, doesn't having them not checked mean you failed?
And if they are not an option not to have unchecked, why have them?
Or make them disabled/checked…
I also realise I wasn’t clear enough in my original question, cc @scottohara.
Not every checkbox is required just that at least one of them in the group is. Maybe seeing the markup will help:
<legend> Group name <span class="h-hide-visually">(select at least one option in order to proceed)</span> </legend> <label for="20385115">Option 1</label> <input type="checkbox" required aria-required="true" value="1234" id="20385115"> <label for="6ec71e57">Option 2</label> <input type="checkbox" required aria-required="true" value="12345" id="6ec71e57"> <label for="9ec055e9">Option 3</label> <input type="checkbox" required aria-required="true" value="123456" id="9ec055e9"> </fieldset>
It does feel funny that every checkbox has a required
attr when only at least one of them in the group is required. I’ve added some hidden visually text to the <legend>
element: <span class="h-hide-visually">(select at least one option in order to proceed)</span>
to let assistive tech users know upfront—is that enough?
For a group of radio buttons the spec says having the required
attr on all of the radio buttons is correct but not sure about a group of checkboxes?