[Django]-How to allow only one radio button to be checked?

604👍

Simply give them the same name:

<input type="radio" name="radAnswer" />

74👍

They need to all have the same name.

53👍

All radio buttons have to have the same name:

<input type='radio' name='foo'>

Only 1 radio button of each group of buttons with the same name can be checked.

👤Nick

25👍

Give them the same name, and it will work. By definition Radio buttons will only have one choice, while check boxes can have many.

<input type="radio" name="Radio1" />

20👍

Add “name” attribute and keep the name same for all the radio buttons in a form.

i.e.,

<input type="radio" name="test" value="value1"> Value 1
<input type="radio" name="test" value="value2"> Value 2
<input type="radio" name="test" value="value3"> Value 3

Hope that would help.

👤SuKu

11👍

Just give them the same name throughout the form you are using.

<form><input type="radio" name="selection">
      <input type="radio" name="selection">
      ..
      ..
</form>

5👍

All the radio buttons options must have the same name for you to be able to select one option at a time.

👤B.K

1👍

Only one Step you need to follow!

Make Sure you need to add the attribute name in the opening tag with the same values of that attribute name!

Example :

<input name="18+" value="yes" id="18" type="radio">Yes
  <input name="18+" value="No" id="bel" type="radio">No

Leave a comment