Javascript DOM HTML Input Search disable and enable

Introduction

Disable and enable a search field:

View in separate window

<!DOCTYPE html>
<html>
<body>

Search: <input type="search" id="mySearch"><br><br>

<button onclick="disableBtn()">Disable Search Field</button>
<button onclick="enableBtn()">enable Search Field</button>

<script>
function disableBtn() {//  w w  w .  j a  v a 2s. c o  m
  document.getElementById("mySearch").disabled = true;
}
function enableBtn() {
  document.getElementById("mySearch").disabled = false;
}
</script>

</body>
</html>



PreviousNext

Related