Javascript DOM HTML Input Datetime max Property set

Introduction

Change the maximum date and time:

document.getElementById("myDatetime").max = "2012-01-01T11:57Z";

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

View in separate window

<!DOCTYPE html>
<html>
<body>

Date and time:/* w ww  . ja  v  a  2s .co m*/
<input type="datetime" id="myDatetime" min="2000-01-01T22:57Z" max="2014-02-06T22:57Z">
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {
  var x = document.getElementById("myDatetime").max = "2012-01-01T11:57Z";
  document.getElementById("demo").innerHTML = "The value of the max attribute was changed.";
}
</script>

</body>
</html>



PreviousNext

Related