How to disable radio button using JavaScript?17 Mar 2025 | 5 min read Radio button is an input type that is used to get input from the user by selecting one value from multiple choices. You have seen the radio buttons to choose gender between male and female. We select only one entry, either male or female and leave the other entries unselected. There might be some cases when we need to disable the other entries based on some conditions. You can enable and disable the radio button by using the disabled property of HTML DOM. Set this property to true (disable=true) to disable the radio button in JavaScript. Disable the radio buttonSometimes, we need to disable the radio button for a specific condition. These are special conditions when we disable the radio button. When the radio buttons get disabled, their color changed to grey. In the below examples, we will learn how to disable the radio button: Disable radio button using dropdownHere, we will use a dropdown list having Yes and No as values to enable or disable the radio buttons. If you choose No, all the radio buttons will be disabled. On the other hand, all the radio buttons will be enabled if you select Yes. Note that you can use the checkbox as well instead of a dropdown list.Copy Code Output 1 You will get the output same as the given below by running the above code. Here, first choose either Yes or No from the dropdown list. ![]() Output 2 By selecting No from the dropdown list, all radio buttons will get disabled, and you will not be allowed to choose any of the programming languages. See the screenshot below: ![]() Output 2 By selecting Yes from the dropdown list, all radio buttons will get enabled again. So, you will be able to choose one programming language. See the screenshot below: ![]() Disable radio button using checkboxNow we will use a checkbox to disable the radio button. Copy Code Output You will get the output same as the given below by running the above code. Here, checkbox is already checked, you just need to choose one programming language by clicking on radio button. ![]() Uncheck the checkbox if you are not a developer. The radio buttons will get disabled by unchecking the checkbox. ![]() So, these are the different methods to disable the radio button. A simple radio button exampleIt is a simple example of radio button created. In this example, we will create set of radio button for gender and language selection. The input will be taken using the HTML form and calculated by JavaScript. See the code below: Copy Code Output See the below screenshot for radio button. Here, selects one value from each set of radio buttons. We have selected gender = female and language = hindi. ![]() After selecting the radio button values, click on the Show Selected Values button, and you will get the selected values have displayed on the web. ![]() Next TopicAws-sdk-for-javascript |
Logical operators are among these tools; they may be important for selection-making, expression evaluation, and execution waft manipulation. When working with Boolean values, logical operators play a crucial role in ensuring that conditions are demonstrated and outcomes are ascertained. JavaScript can now effectively carry out operations...
5 min read
In JavaScript, a fixed collection of named values is represented via enums. They enable programmers to create a list of named constants that may be used across the codebase to improve error ention, readability, and maintainability. Enumerations, often known as enums, are used in JavaScript to...
11 min read
An essential component of the language, JavaScript arrays offer a flexible and potent means of managing data sets. The ability to manipulate arrays is essential for any JavaScript developer. An Overview of Arrays in JavaScript JavaScript arrays are an essential and adaptable data structure that is essential...
11 min read
JavaScript string includes() The JavaScript includes() method is used to check if a specified substring is present in a given string. It is a case-sensitive method. It returns the Boolean value, either true or false. It returns true if the string contains the specified substring and...
2 min read
We will understand the composition in JavaScript in this article. As the word "composition" means combining two or more things together to compose a new thing. Function Composition In JavaScript, there is a technique called the function composition. This technique is utilized to combine two or more functions...
3 min read
What is the background color? Using the background color feature, it is possible to insert a background color for a web page. The background-color property within an HTML element will be responsible for this. This affects the whole size of the element that has been specified, except...
4 min read
FizzBuzz is a classic coding problem often used in technical interviews to assess a candidate's basic programming skills. Despite its simplicity, it's a good test of one's ability to understand conditional logic and loop structures. In this article, we'll explore how to implement , discussing...
10 min read
What is a Hash Table in JavaScript? In JavaScript, a Hash table, also known as a hash map, is considered a data structure that helps us store key-value pairs more efficiently. Using hash functions, we can map keys to indices in an array, which allows for faster...
8 min read
JavaScript, as one of the most broadly utilized programming languages, offers developers a heap of instruments and functions to successfully handle asynchronous tasks. One such instrument is the then() function, an urgent part of JavaScript's Promise Programming interface. The then() function assumes a vital part...
6 min read
Web developers, much of the time use JavaScript, a dynamic and adaptable programming language, to make dynamic and intelligent UIs. Data control is one of its various highlights, and grouping components as per explicit measures is one of the regular exercises in data control. This is...
5 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India