In this article, you will learn how to disable radio button. We will discuss two ways for disabling a radio button.
So, to disable a radio button, we can simply use the disabled attribute. On the other hand, we can use JavaScript checked property.
Disable a radio button using HTML attribute. #
In the first example, we will use the HTML disabled attribute to disable a radio button. Syntax :
<input type="radio" disabled="">
Click on the Try it Yourself » button to open the code in our online editor.
How to disable radio button in JavaScript. #
In the second example, we will use JavaScript checked property. The example is given below.
<input onclick="this.checked=false;" type="radio">
Comments (0)