Get the maximum month and year allowed for a month field:
var x = document.getElementById("myMonth").max;
Click the button to display the value of the max attribute of the month field.
input elements with type=month is not supported in Firefox.</p>
<!DOCTYPE html> <html> <body> Enter a month between 2020-04 and 2020-09 (April to September): <input type="month" id="myMonth" min="2020-04" max="2020-09"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w. j a v a 2 s.co m var x = document.getElementById("myMonth").max; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The max
property sets or gets the value of the max attribute of a month field.
The max attribute sets the maximum value in month and year for a month field.
The <input type="month"> element is not supported in Firefox.
Value | Description |
---|---|
YYYY-MM | Specifies the maximum month and year allowed. YYYY - year (e.g. 2020) MM - month (e.g. 01 for January) |
The max
property returns a String representing the maximum month and year allowed.