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