Javascript examples for DOM HTML Element:Input Datetime Local
The readOnly property sets or gets whether a local 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 local datetime field should be read-only |
A Boolean, returns true if the local datetime field is read-only, otherwise it returns false
The following code shows how to Set a local datetime field to read-only:
<!DOCTYPE html> <html> <body> <input type="datetime-local" id="myLocalDate" readonly> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w . ja va 2 s.c om*/ document.getElementById("myLocalDate").readOnly = true; var x = document.getElementById("myLocalDate").readOnly; document.getElementById("demo").innerHTML = x; } </script> </body> </html>