Javascript DOM HTML Input Week step Property set

Introduction

Change the legal week intervals:

document.getElementById("myWeek").step = "2";

Click the button to change the value of the step attribute of the week field.

input elements with type="week" are not supported in Internet Explorer or Firefox.

View in separate window

<!DOCTYPE html>
<html>
<body>

Week: <input type="week" id="myWeek">
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {// w w w .  j  a va2s .  c  o  m
  document.getElementById("myWeek").step = "2";
  document.getElementById("demo").innerHTML = "Step was set to '2', the user can only select every second week in the calendar.";
}
</script>

</body>
</html>

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

The step attribute sets the week intervals to choose from.

For example, if step = "2", you can only select every second week in the calendar.

The <input type="week"> element is not supported in Firefox.

Value Description
number Specifies the legal week intervals. Default is 1 week.

If step="2", you can only select every second week in the week calendar.

If step="10", you can only select every tenth week in the week calendar.

The step property returns a Number, representing the legal week intervals.




PreviousNext

Related