Javascript DOM HTML Input Month readOnly Property get

Introduction

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

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

Click the button to find out if the month field is read-only or not.

input elements with type=month is not supported in Firefox.

View in separate window

<!DOCTYPE html>
<html>
<body>

<input type="month" id="myMonth" readonly>
<button onclick="myFunction()">Test</button>

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

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

</body>
</html>



PreviousNext

Related