Javascript DOM HTML Input Month min Property set

Introduction

Change the minimum value:

document.getElementById("myMonth").min = "2020-01";

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

input elements with type=month is not supported in Firefox.

View in separate window

<!DOCTYPE html>
<html>
<body>

Month:/*  ww w  . ja v  a 2 s . co m*/
<input type="month" id="myMonth" min="2014-04" max="2014-09">
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

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

</body>
</html>



PreviousNext

Related