HTML <input> Tag with 'type=week'

<form name="myForm" action="">
<input type="week" name="myWeekField">


The above example demonstrates usage of the <input> element with the type attribute set to week (i.e. type="week").

The week value represents a control for setting the element's value to a string representing a specific week. This is a date consisting of a year and a week with no time zone.

Specifying a min and/or max Date

The min and max attributes can be used with the week field to specify a minimum and maximum week. If specified, they must have a value that is a valid week string.

The following example specifies a min week of 1 week ago and a max week of 1 week's time. The user can only select the weeks that fall within that range.

<form name="myForm2" action="">
<input type="week" min="2024-W15" max="2024-W17" name="myWeekField2">


Specifying a step

You can also use the step attribute to limit the number of weeks the user can choose from.

The following example uses a step value of 2, resulting in every second week being unavailable.

<form name="myForm3" action="">
<input type="week" step="2" name="myWeekField3">


Note: The week value was not introduced in HTML5, but at the time of writing, it has been introduced in the HTML 5.1 draft, as well as the WHATWG HTML Living Standard.

You can also use the datetime, datetime-local, time, month, and date values when working with dates and times.