Javascript examples for DOM HTML Element:Input Month
The readOnly property sets or gets whether a month field should be read-only.
This property reflects the HTML readonly attribute.
Set the readOnly property with the following Values
Value | Description |
---|---|
true|false | Sets whether a month field should be read-only |
A Boolean, returns true if the month field is read-only, otherwise it returns false
The following code shows how to Set a month field to read-only:
<!DOCTYPE html> <html> <body> <input type="month" id="myMonth" readonly> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w ww. ja v a 2 s .co m document.getElementById("myMonth").readOnly = true; document.getElementById("demo").innerHTML = "changed"; } </script> </body> </html>