HTML DOM Input DatetimeLocal disabled Property


The HTML DOM Input DatetimeLocal disabled property sets/returns whether Input DatetimeLocal is enabled or disabled.

Syntax

Following is the syntax −

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

Boolean Values

Here, “booleanValue” can be the following −

booleanValueDetails
trueIt defines that the input datetimeLocal is disabled.
falseIt defines that the input datetimeLocal is not disabled and it is also the default value.

Example

Let us see an example of Input DatetimeLocal disabled property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>Input DatetimeLocal 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>Datetime-Local-disabled</legend>
<label for="datetimeLocalSelect">Examination Time:
<input type="datetime-local" id="datetimeLocalSelect" value="2019-07-05T20:45" disabled>
</label>
<input type="button" onclick="enableDatetimeLocalInput()" value="Change Examination Date and Time">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var inputDatetimeLocal = document.getElementById("datetimeLocalSelect");
   divDisplay.textContent = 'DatetimeLocal Input disabled: '+inputDatetimeLocal.disabled;
   function enableDatetimeLocalInput() {
      inputDatetimeLocal.disabled = false;
      divDisplay.textContent = 'DatetimeLocal Input disabled: '+inputDatetimeLocal.disabled;
   }
</script>
</body>
</html>

Output

This will produce the following output −

Before clicking ‘Change Examination Date and Time’ button −

After clicking ‘Change Examination Date and Time’ button −

Updated on: 30-Jul-2019

43 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements