The readOnly
property sets or gets whether a month field should be read-only.
readOnly |
Yes | No | No | Yes | Yes |
Return the readOnly property.
var v = monthObject.readOnly
Set the readOnly property.
monthObject.readOnly=true|false
Value | Description |
---|---|
true|false | Set whether a month field should be read-only
|
A Boolean type value, true if the month field is read-only, otherwise false.
The following code shows how to check if a month field is read-only.
<!DOCTYPE html>
<html>
<body>
<input type="month" id="myMonth" readonly>
<button onclick="myFunction()">test</button>
<!--from w ww . j a v a 2s. c o m-->
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("myMonth").readOnly;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to set a month field to read-only.
<!DOCTYPE html>
<html>
<body>
<input type="month" id="myMonth">
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!-- w w w.j a v a2 s.com-->
document.getElementById("myMonth").readOnly = true;
}
</script>
</body>
</html>
The code above is rendered as follows: