Javascript Reference - HTML DOM Input Week disabled Property








The disabled property disables or enables a week field.

Browser Support

disabled Yes No No Yes Yes

Syntax

Return the disabled property.

var v = weekObject.disabled 

Set the disabled property.

weekObject.disabled=true|false

Property Values

Value Description
true|false Disable or enable a week input control
  • true - The week field is disabled
  • false - Default. The week field is not disabled




Return Value

A Boolean type value, true if the week field is disabled, otherwise false.

Example

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:





Example 2

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: