0

I have two radio buttons in a form in the same radio group :

<li><input name="gender" type="radio" value="Male" /><label class="label_gender" required> Male</label></li>
<li><input name="gender" type="radio" value="Female" /><label class="label_gender" required> Female</label></li>

I want to make this radio group required, as you see I used the required attribute for both f them, but it doesn't work.

for other inputs as text or email, the required attribute works fine.

How can I make my radio buttons required ?

maelswarm
  • 1,163
  • 4
  • 18
  • 37
Renaud is Not Bill Gates
  • 1,684
  • 34
  • 105
  • 191
  • This should help :) [http://stackoverflow.com/questions/8287779/html5-how-to-use-the-required-attribute-in-an-input-field-with-type-radio][1] [1]: http://stackoverflow.com/questions/8287779/html5-how-to-use-the-required-attribute-in-an-input-field-with-type-radio – user3316437 Feb 17 '14 at 10:23

1 Answers1

3

The required attribute should be added to the input element, not the label element.

Change your markup to:

<li><input name="gender" type="radio" value="Male" required /><label class="label_gender"> Male</label></li>
<li><input name="gender" type="radio" value="Female" required /><label class="label_gender"> Female</label></li>
James Donnelly
  • 126,410
  • 34
  • 208
  • 218