Javascript DOM HTML Input Date max Property set

Introduction

Change the maximum date:

document.getElementById("myDate").max = "2014-01-01";

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

View in separate window

<!DOCTYPE html>
<html>
<body>

Date://from w ww . jav a 2 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").max = "2014-01-01";
  document.getElementById("demo").innerHTML = "The value of the max attribute was changed.";
}
</script>

</body>
</html>



PreviousNext

Related