Javascript DOM HTML Input Datetime readOnly Property get

Introduction

Find out if a datetime field is read-only:

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

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

View in separate window

<!DOCTYPE html>
<html>
<body>

Birthday: <input type="datetime" id="myDatetime" readonly>
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {//from   w w w . j  av a  2  s.c o m
  var x = document.getElementById("myDatetime").readOnly;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related