Fieldset disabled Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Fieldset

Description

The disabled property sets or gets whether a form fieldset is disabled.

This property reflects the HTML disabled attribute.

Set the disabled property with the following Values

Value Description
true|false Sets whether a group of related form elements (a fieldset) should be disabled
  • true - The fieldset is disabled
  • false - Default. The fieldset is not disabled

Return Value

A Boolean, returns true if the fieldset is disabled, otherwise it returns false

The following code shows how to disable a fieldset:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<form>
  <fieldset id="myFieldset">
    <legend>Personalia:</legend>
    Name: <input type="text"><br>
    Email: <input type="text"><br>
    Date of birth: <input type="text">
  </fieldset>
</form>/*  w w  w .  j  a  va2 s  .com*/

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {
    document.getElementById("myFieldset").disabled = true;
}
</script>
</body>
</html>

Related Tutorials