Javascript DOM HTML Fieldset disabled Property set

Introduction

Disable a fieldset:

document.getElementById("myFieldset").disabled = true;

Click the button below to to disable the fieldset above.

View in separate window

<!DOCTYPE html>
<html>
<body>

<form>
  <fieldset id="myFieldset">
  <legend>MyNameFieldset:</legend>
  Name: <input type="text"><br>
  Email: <input type="text"><br>
  Date of birth: <input type="text">
  </fieldset>
</form>/*from  w w  w.j  a v  a2 s.  co m*/
<button onclick="myFunction()">Test</button>

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

</body>
</html>

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

If this property is set, the form elements in the fieldset are disabled.

This property mirrors the HTML disabled attribute.

The disabled property accepts and returns a boolean type value.

Property Values

Value Description
true The fieldset is disabled
false Default. The fieldset is not disabled

The disabled property returns true if the fieldset is disabled, otherwise it returns false.




PreviousNext

Related