The min
property sets or gets the min attribute of a month field.
The min
attribute sets the minimum month and year value for a month field.
min |
Yes | No | No | Yes | Yes |
Return the min property.
var v = monthObject.min
Set the min property.
monthObject.min=YYYY-MM
Value | Description |
---|---|
YYYY-MM | Set the minimum month and year allowed.
|
A String type value representing the minimum month and year allowed.
The following code shows how to change the minimum value.
<!DOCTYPE html>
<html>
<body>
<!--from w ww.j av a 2 s. co 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").min= "2014-01";
}
</script>
</body>
</html>
The code above is rendered as follows:
The following code shows how to get the minimum month and year allowed for a month field.
<!DOCTYPE html>
<html>
<body>
<!--from w w w. j av a 2s. 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").min;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>
The code above is rendered as follows: