How to Disable Specific Readio Button Option using JavaScript? Last Updated : 30 Apr, 2024 Comments Improve Suggest changes Like Article Like Report In this article, we will disable a specific radio button using JavaScript. Disabling specific radio button options using JavaScript involves targeting the specific option and then set its disabled property to true. This can be done by selecting the radio button option and modifying its disabled property accordingly. Disabling a radio button option prevents the user from selecting it, but the option remains visible.Disabled radio button options are not included in form submissions, so their values are not sent to the server.Table of Content Using setAttribute() and removeAttribute() MethodsUsing the disabled PropertyApproach 1: Using setAttribute() and removeAttribute() MethodsThe setAttribute method adds the disabled attribute to a specific radio button option and the removeAttribute() method remove it. This approach allow to dynamically enable or disable specific options based on certain conditions. HTML <!DOCTYPE html> <html> <head> <title> How to Disable Specific Readio Button Option using JavaScript? </title> </head> <body> <p>Select Subject</p> <input type="radio" id="html" name="radioGroup" value="html"> <label for="html">HTML</label> <br> <input type="radio" id="css" name="radioGroup" value="css"> <label for="css">CSS</label> <br> <input type="radio" id="js" name="radioGroup" value="javascript"> <label for="js">JavaScript</label> <br><br> <button onclick="disableOption()"> Disable JavaScript </button> <script> function disableOption() { let option = document.getElementById("js"); option.setAttribute("disabled", "disabled"); } </script> </body> </html> Output: Approach 2: Using the disabled PropertyYou can also directly manipulate the disabled property of the specific radio button option to enable or disable it. This approach is very basic and does not require setting or removing attributes. HTML <!DOCTYPE html> <html> <head> <title> How to Disable Specific Readio Button Option using JavaScript? </title> </head> <body> <p>Select Subject</p> <input type="radio" id="html" name="radioGroup" value="html"> <label for="html">HTML</label> <br> <input type="radio" id="css" name="radioGroup" value="css"> <label for="css">CSS</label> <br> <input type="radio" id="js" name="radioGroup" value="javascript"> <label for="js">JavaScript</label> <br><br> <button onclick="disableOption()"> Disable JavaScript </button> <script> function disableOption() { let option = document.getElementById("js"); option.disabled = true; } </script> </body> </html> Output: Comment More infoAdvertise with us Next Article How to Disable Specific Readio Button Option using JavaScript? P ppatelkap Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Similar Reads How to disable radio button using JavaScript ? Radio buttons let users select one option from many, commonly used in forms. Sometimes, based on a user's previous choice, certain options need to be disabled. For example, if a user selects "No" to playing games, we can disable related game options. Using JavaScript, about 65% of forms use such log 4 min read How to Disable Radio Button in HTML? This article will show you how to disable Radio Button in HTML. The disabled attribute is used to disable a radio button in HTML. This attribute prevents the radio button from being selected by the user. Using the disabled AttributeThe disabled attribute is used to disable the input fields. To disab 2 min read How to disable right-click option using the jQuery ? The bind() method in jQuery is used to attach one or more event handlers for selected element and this method specifies a function to run when an event occurs. Syntax: $(selector).bind(event, data, function);Parameters: This method accepts three parameters as mentioned above and described below: eve 2 min read How to Disable Button Element Dynamically using JavaScript? The disabled property in the HTML DOM is used to control the interactivity of a button element. When this property is set, the button becomes unclickable and inactive, effectively preventing any user interaction. This property accepts a boolean value, allowing developers to dynamically enable or dis 1 min read How to make a Disable Buttons using jQuery Mobile ? jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops. In this article, we will be making a Disable Button using jQuery Mobile. Approach: First, add jQuery Mobile scripts needed for your project. <link rel="stylesheet 1 min read How to create a Disabled Option Select using jQuery Mobile ? jQuery Mobile is a web-based technology used to make responsive content that can be accessed on all smartphones, tablets, and desktops. In this article, we will be creating a Disabled Option Select using jQuery Mobile. Approach: First, add jQuery Mobile scripts needed for your project. <link rel= 1 min read How to Disable a Button in jQuery UI ? To disable a button in jQuery UI, we will be using disable() method which is discussed below: jQuery UI disable() method is used to completely disable the button. It returns the button element completely to its initial state. Syntax: $(".selector").button("disable") Parameters: This method does not 2 min read How to remove âdisabledâ attribute from HTML input element using JavaScript ? In HTML, we use input elements for user input. The 'disabled' property helps prevent interaction with these elements. For example, if we only want users over 18 to input their Adhar card numbers, we can use JavaScript to remove the 'disabled' attribute when the user enters an age greater than 18. Th 2 min read jQuery UI Button disabled Option jQuery UI consists of GUI widgets, visual effects, and themes implemented using HTML, CSS, and jQuery. jQuery UI is great for building UI interfaces for the webpages. The jQuery UI Button disabled option is used to disable the button element if it set to true. Syntax: $( ".selector" ).button({ disab 1 min read How to enable/disable a button using jQuery ? Enabling/disabling a button using jQuery involves altering its functionality to either accept user input or not. This is typically done by manipulating its 'disabled' property or attribute through jQuery methods like `.prop()` or .attr().To enable/disable a button using jQuery, you'll need a basic H 2 min read Like