Javascript DOM HTML Input Search readOnly Property get

Introduction

Find out if a search field is read-only or not:

var x = document.getElementById("mySearch").readOnly;

Click the button to find out if the search field is read-only.

View in separate window

<!DOCTYPE html>
<html>
<body>

Search: <input type="search" id="mySearch" readonly>
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from   w  w w  .jav  a2 s .c om*/
  var x = document.getElementById("mySearch").readOnly;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related