HTML DOM Input Week max Property


The HTML DOM Input Week max property returns/sets max attribute of Input Week.

Syntax

Following is the syntax −

  • Returning string value
inputWeekObject.max
  • Setting max to string value
inputWeekObject.max = YYYY-Www

String Values

Here, “YYYY-Www” can be the following −

stringValueDetails
YYYYIt defines year (eg:2017)
WIt is a separator for year and week
wwIt defines weeks (eg:52)

Example

Let us see an example for Input Week max property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<title>Input Week max</title>
<style>
   form {
      width:70%;
      margin: 0 auto;
      text-align: center;
   }
   * {
      padding: 2px;
      margin:5px;
   }
   input[type="button"] {
      border-radius: 10px;
   }
</style>
</head>
<body>
<form>
<fieldset>
<legend>Week-max</legend>
<label for="WeekSelect">Ongoing Week:
<input type="week" id="WeekSelect" value="2020-W01" max="2019-W52" disabled>
</label>
<input type="button" onclick="renewInsurance()" value="Renew Insurance">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var inputWeek = document.getElementById("WeekSelect");
   divDisplay.textContent = 'Insurance Expired as of: Week'+inputWeek.max.split("-W")[1];
   divDisplay.textContent += ' ,'+inputWeek.max.split("-W")[0];
   function renewInsurance() {
      inputWeek.max = '2029-W52';
      divDisplay.textContent = 'Insurance Renewed till: Week'+inputWeek.max.split("-W")[1];
      divDisplay.textContent += ' ,'+inputWeek.max.split("-W")[0];
   }
</script>
</body>
</html>

Output

This will produce the following output −

Before clicking ‘Renew Insurance’ button −

After clicking ‘Renew Insurance’ button −

Updated on: 30-Jul-2019

69 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements