Javascript DOM HTML Input Date disabled Property set

Introduction

Disable a date field:

document.getElementById("myDate").disabled = true;

Click the button to disable the date field.

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="date" id="myDate">

<button onclick="myFunction()">Test</button>
<script>
function myFunction() {//from  ww  w  . ja  v a 2s.c o  m
  document.getElementById("myDate").disabled = true;
}
</script>

</body>
</html>

The disabled property sets or gets whether a date field should be disabled or not.

This property mirrors the HTML disabled attribute.

The disabled property accepts and returns a boolean value.

Value Description
true The date field is disabled
false Default. The date field is not disabled

It returns true if the date field is disabled, otherwise it returns false.




PreviousNext

Related