The disabled
property sets or gets whether a fieldset is disabled.
If this property is set, the form elements in the fieldset are disabled.
disabled |
Yes | Yes | Yes | Yes | Yes |
Return the disabled property.
var v = fieldsetObject.disabled
Set the disabled property.
fieldsetObject.disabled=true|false
Value | Description |
---|---|
true|false | Specifies whether a fieldset should be disabled
|
A Boolean type value, true if the fieldset is disabled, otherwise it returns false.
The following code shows how to find out if a fieldset is disabled or not.
<!DOCTYPE html>
<html>
<body>
<form>
<fieldset id="myFieldset" disabled>
<legend>Information:</legend>
Name: <input type="text"><br>
Email: <input type="text"><br>
Date of birth: <input type="text">
</fieldset>
</form><!--from ww w . j av a2 s. co m-->
<p id="demo"></p>
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
var x = document.getElementById("myFieldset").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 fieldset.
<!DOCTYPE html>
<html>
<body>
<!--from w ww . j a va2s . c o m-->
<form>
<fieldset id="myFieldset">
<legend>Information:</legend>
Name: <input type="text"><br>
Email: <input type="text"><br>
Date of birth: <input type="text">
</fieldset>
</form><br>
<button onclick="disableField()">Disable fieldset</button>
<button onclick="undisableField()">Undisable fieldset</button>
<script>
function disableField() {
document.getElementById("myFieldset").disabled = true;
}
function undisableField() {
document.getElementById("myFieldset").disabled = false;
}
</script>
</body>
</html>
The code above is rendered as follows: