Javascript Reference - HTML DOM Input Week min Property








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

The min attribute sets the minimum week and year for a week field.

Browser Support

min Yes No No Yes Yes

Syntax

Return the min property.

var v = weekObject.min

Set the min property.

weekObject.min=YYYY-WWW




Property Values

Value Description
YYYY-WWW Specifies the minimum week and year allowed.
  • YYYY - year (e.g. 2014)
  • '-W' is the separator for 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

Return Value

A String type value, representing the minimum week and year allowed.

Example

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


<!DOCTYPE html>
<html>
<body>
<!--from  w  w w. ja va  2 s.  c o  m-->
Week and Year:
<input type="week" id="myWeek" min="2014-W12" max="2014-W19">
<button onclick="myFunction()">test</button>
<script>
function myFunction() {
    var x = document.getElementById("myWeek").min = "2014-W16";
}
</script>
</body>
</html>

The code above is rendered as follows:





Example 2

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


<!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() {<!--  w ww.j  av  a2  s . c o m-->
    var x = document.getElementById("myWeek").min;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows: