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