Javascript DOM HTML Textarea disable and enable

Introduction

Disable and enable a text area:

View in separate window

<!DOCTYPE html>
<html>
<body>

Address:<br>
<textarea id="myTextarea">
PO 1234, Main Street U.S.A.
New York</textarea>
<br>

<button onclick="disableTxt()">Disable text area</button>
<button onclick="enableTxt()">enable text area</button>

<script>
function disableTxt() {/*from  w w  w  . j  a va 2 s .  c  o m*/
  document.getElementById("myTextarea").disabled = true;
}
function enableTxt() {
  document.getElementById("myTextarea").disabled = false;
  }
</script>

</body>
</html>



PreviousNext

Related