Demo: Enable or Disable Radio Buttons

Check “Enable gender choices” to activate the radio buttons. Clear it to disable the group again.

Gender

JavaScript Used in This Demo Top ↑

const toggle = document.getElementById("enableGender");
const radios = document.querySelectorAll('input[name="gender"]');

toggle.addEventListener("change", () => {
  radios.forEach((radio) => {
    radio.disabled = !toggle.checked;
  });
});

HTML Used in This Demo Top ↑

<input type="checkbox" id="enableGender" name="others" value="yes"> Enable gender choices
<input type="radio" name="gender" value="male" disabled> Male
<input type="radio" name="gender" value="female" disabled> Female

Enable/disable radio tutorial




Subscribe to our YouTube Channel here



plus2net.com










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer