HTML <input> Tag with 'type=week'

<form name="myForm" action="http://www.htmlcodes.ws/resources/html-forms-action.cfm">
	
<input type="week" name="myWeekField">

<button>Submit</button>
</form>

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="http://www.htmlcodes.ws/resources/html-forms-action.cfm">
	
<input type="week" min="2017-W41" max="2017-W43" name="myWeekField2">

<button>Submit</button>
</form>

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="http://www.htmlcodes.ws/resources/html-forms-action.cfm">
	
<input type="week" step="2" name="myWeekField3">

<button>Submit</button>
</form>

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.