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