The max
property sets or gets the max attribute of a month field.
The max
attribute sets the maximum month and year value for a month field.
max |
Yes | No | No | Yes | Yes |
Return the max property.
var v = monthObject.max
Set the max property.
monthObject.max=YYYY-MM
Value | Description |
---|---|
YYYY-MM | Sets the maximum month and year allowed.
|
A String type value representing the maximum month and year allowed.
The following code shows how to change the maximum month and year.
<!DOCTYPE html>
<html>
<body>
<!--from ww w . j a v a 2s .c o m-->
Month:
<input type="month" id="myMonth" min="2014-04" max="2014-09">
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
var x = document.getElementById("myMonth").max = "2014-12";
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to get the maximum month and year allowed for a month field.
<!DOCTYPE html>
<html>
<body>
<!--from w w w. ja va 2 s . co m-->
Enter a month between 2014-04 and 2014-09:
<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;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: