Javascript DOM HTML Input DatetimeLocal readOnly Property get

Introduction

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

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

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

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="datetime-local" id="myLocalDate" readonly>
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {/*from   ww w . j av a2 s .  co  m*/
  var x = document.getElementById("myLocalDate").readOnly;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related