Javascript DOM HTML Input Month max Property set

Introduction

Change the maximum month and year:

document.getElementById("myMonth").max = "2014-12";

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

input elements with type=month is not supported in Firefox.</p>

View in separate window

<!DOCTYPE html>
<html>
<body>

Month:// w w  w.  j  a v  a 2 s.  com
<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").max = "2014-12";
  document.getElementById("demo").innerHTML = "The value of the max attribute was changed.";
}
</script>

</body>
</html>



PreviousNext

Related