The disabled
property disables or enables a radio button.
disabled |
Yes | Yes | Yes | Yes | Yes |
Return the disabled property.
var v = radioObject.disabled
Set the disabled property.
radioObject.disabled=true|false
Value | Description |
---|---|
true|false | Disable or enable a radio button.
|
A Boolean type value, true if the radio button is disabled, otherwise false.
The following code shows how to get if a radio button is disabled.
<!DOCTYPE html>
<html>
<body>
Radio Button: <input type="radio" id="myRadio">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!--from w w w . j a v a 2 s. c o m-->
var x = document.getElementById("myRadio").disabled;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to disable and enable a radio button.
<!DOCTYPE html>
<html>
<body>
<!-- w ww . j av a 2s.c o m-->
Radio Button: <input type="radio" id="myRadio">
<button onclick="disable()">Disable radio button</button>
<button onclick="enable()">Enable radio button</button>
<script>
function disable() {
document.getElementById("myRadio").disabled = true;
}
function enable() {
document.getElementById("myRadio").disabled = false;
}
</script>
</body>
</html>
The code above is rendered as follows: