The disabled
property disable or enable a date field.
disabled |
Yes | No | No | Yes | Yes |
Return the disabled property.
var v = inputdateObject.disabled
Set the disabled property.
inputdateObject.disabled=true|false
Value | Description |
---|---|
true|false | Disable or enable a date field
|
A Boolean type value, true if the date field is disabled, otherwise false.
The following code shows how to get if a date field is disabled.
<!DOCTYPE html>
<html>
<body>
<input type="date" id="myDate" disabled>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!-- w w w . j av a 2s.c o m-->
var x = document.getElementById("myDate").disabled;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to disable and enabled a date field.
<!DOCTYPE html>
<html>
<body>
<!--from ww w . j a va2s .c o m-->
<input type="date" id="myDate"><br><br>
<button onclick="disableBtn()">Disable Date Field</button>
<button onclick="enableBtn()">Enable Date Field</button>
<script>
function disableBtn() {
document.getElementById("myDate").disabled = true;
}
function enableBtn() {
document.getElementById("myDate").disabled = false;
}
</script>
</body>
</html>
The code above is rendered as follows: