Javascript DOM HTML Fieldset disable and enable a fieldset

Introduction

Disable and enable a fieldset:

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><br>

<button onclick="disableField()">Disable fieldset</button>
<button onclick="enableField()">enable fieldset</button>

<script>
function disableField() {//from   w ww.jav a  2s .  c om
  document.getElementById("myFieldset").disabled = true;
}

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

</body>
</html>



PreviousNext

Related