Javascript DOM HTML Input Date readOnly Property get

Introduction

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

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

Click the button to find out whether the date field is read-only, or not.

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="date" id="myDate" readonly>
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {/*w ww.j  a va  2s .co m*/
  var x = document.getElementById("myDate").readOnly;
  document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>



PreviousNext

Related