Javascript Reference - HTML DOM Input Week max Property








The max property sets or gets the value of the max attribute of a week field.

The max attribute sets the maximum week and year for a week field.

Browser Support

max Yes No No Yes Yes

Syntax

Return the max property.

weekObject.max 

Set the max property.

weekObject.max=YYYY-WWW




Property Values

Value Description
YYYY-WWW Specifies the maximum week and year allowed.
  • YYYY - year (e.g. 2011)
  • '-W' is the week separator
  • WW - week in the range of 1 to 52 or 53, e.g. 01 for the first week of the year
Example: 2014-W15

Return Value

A String type value representing the maximum week and year allowed.

Example

The following code shows how to change the maximum week and year allowed.


<!DOCTYPE html>
<html>
<body>
<input type="week" id="myWeek" min="2014-W12" max="2014-W19">
<button onclick="myFunction()">test</button>
<script>
function myFunction() {<!--from  ww w  . ja  v  a2s  .  co  m-->
    var x = document.getElementById("myWeek").max = "2014-W35";
}
</script>

</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to get the maximum week and year allowed for a week field.


<!DOCTYPE html>
<html>
<body>
<!--from  w  ww . j  a va 2  s  .  c om-->
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() {
    var x = document.getElementById("myWeek").max;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: