Javascript DOM HTML Input Datetime min Property set

Introduction

Change the minimum date and time:

document.getElementById("myDatetime").min = "2010-02-02T21:57Z";

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

View in separate window

<!DOCTYPE html>
<html>
<body>

Date and time:/*from  ww w. j a va2 s. 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").min = "2010-02-02T21:57Z";
  document.getElementById("demo").innerHTML = "The value of the min attribute was changed.";
}
</script>

</body>
</html>



PreviousNext

Related