Input Week value attribute

Definition and Usage

value Attribute settings or return the value of the value attribute of the week field.

The HTML value attribute specifies the week and year for the week field.

See Also:

HTML Reference Manual:HTML <input> value Attribute

Example

Example 1

Set the week and year of the week field:

document.getElementById("myWeek").value = "2023-W06";

Try It Yourself

Example 2

Get the week and year of the week field:

var x = document.getElementById("myWeek").value;

Try It Yourself

Syntax

Return value attribute:

weekObject.value

Set value attribute:

weekObject.value = YYYY-WWW

Attribute Value

Value Description
YYYY-WWW

Specify week and year.

Component Description:

  • YYYY - Year (for example, 2023)
  • String "-W" indicates "week"
  • WW - Week (within the range of 1 to 52 or 53, depending on the specific year, for example, 01 represents the first week of the year)

For example: 2023-W36

Technical Details

Return Value: A string value representing the year and week of the week field.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support

Note:The <input type="week"> element does not display any date field/calendar in Firefox.