Javascript DOM HTML Input Date min Property set

Introduction

Change the minimum date:

document.getElementById("myDate").min = "1999-01-01";

Click the button to change the value of the min attribute of the date field.

View in separate window

<!DOCTYPE html>
<html>
<body>

Date:/* ww  w  .  j  a v  a2  s.c o  m*/
<input type="date" id="myDate" name="bday" min="1980-01-01" max="2000-01-01">
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {
  var x = document.getElementById("myDate").min = "1999-01-01";
  document.getElementById("demo").innerHTML = "The value of the min attribute was changed.";
}
</script>

</body>
</html>



PreviousNext

Related