HTML DOM Input Week disabled Property

HTMLWeb DevelopmentFront End Technology

The Input Week disabled property sets/returns whether Input Week is enabled or disabled.

Syntax

Following is the syntax −

  • Returning boolean value - true/false
inputWeekObject.disabled
  • Setting disabled to booleanValue
inputWeekObject.disabled = booleanValue

Boolean Values

Here, “booleanValue” can be the following −

booleanValue
Details
True
It defines that the input week is disabled.
False
It defines that the input week is not disabled and it is also the default value.

Example

Let us see an example for Input Week disabled property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>Input Week Disabled</title>
<style>
   form {
      width:70%;
      margin: 0 auto;
      text-align: center;
   }
   * {
      padding: 2px;
      margin:5px;
   }
   input[type="button"] {
      border-radius: 10px;
   }
</style>
</head>
<body>
<form>
<fieldset>
<legend>Week-disabled</legend>
<label for="WeekSelect">Sales Target Week:
<input type="week" id="WeekSelect" value="2020-W13" disabled>
</label>
<input type="button" onclick="enableWeekInput()" value="Change Sales Target Week">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var inputWeek = document.getElementById("WeekSelect");
   divDisplay.textContent = 'Week Input disabled: '+inputWeek.disabled;
   function enableWeekInput() {
      inputWeek.disabled = false;
      divDisplay.textContent = 'Week Input disabled: '+inputWeek.disabled;
   }
</script>
</body>
</html>

Output

This will produce the following output −

Before clicking ‘Change Sales Target Week’ button −

After clicking ‘Change Sales Target Week’ button −

raja
Published on 26-Jul-2019 13:40:49
Advertisements