Get the maximum week and year allowed for a week field:
var x = document.getElementById("myWeek").max;
Click the button to display the value of the max attribute of the week field.
input elements with type="week" are not supported in Internet Explorer or Firefox.
<!DOCTYPE html> <html> <body> Enter a week between Week 12 and Week 19 in 2014: <input type="week" id="myWeek" min="2014-W12" max="2014-W19"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w .j a v a2s . c om*/ var x = document.getElementById("myWeek").max; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The max property sets or gets the max attribute of a week field.
The max attribute sets the maximum week and year for a week field.
The <input type="week"> element is not supported in Firefox.
Value | Description |
---|---|
YYYY-WWW Specifies the maximum week and year allowed. YYYY - year (e.g. 2020) The literal string "-W" indicates "week" WW - week (in the range of 1 to 52 or 53, e.g. 01 for the first week of the year) Example: 2014-W15 |
The max property returns a String representing the maximum week and year allowed.