Input Week max Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Week

Description

The max property sets or gets the max attribute of a week field, which sets the maximum week and year for a week field.

Set the max property with the following Values

ValueDescription
YYYY-WWW Sets the maximum week and year allowed.
  • YYYY - year (e.g. 2011)
  • The literal string "-W" indicates "week"
  • WW - week (in the range of 1 to 52 or 53)

Example: 2018-W15

Return Value

A String, representing the maximum week and year allowed

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

Week and Year:/*from  w w w .j  ava  2 s . co m*/
<input type="week" id="myWeek" min="2018-W12" max="2018-W19">

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myWeek").max;
    document.getElementById("demo").innerHTML = v;
}
</script>

</body>
</html>

Related Tutorials