📅  最后修改于: 2023-12-03 15:01:14.935000             🧑  作者: Mango
The <input type="week">
element is used in HTML forms to let the user input a week date, represented by a string in the format YYYY-Www
, where YYYY
is the year and Www
is the ISO week number.
<input type="week" name="...">
The name
attribute specifies the name of the input element, and is used to identify the form data on the server side.
<form>
<label for="weekdate">Select a week:</label>
<input type="week" id="weekdate" name="weekdate">
<input type="submit" value="Submit">
</form>
The above code will create a form with a "Select a week" label and a <input type="week">
element, followed by a submit button. When the user submits the form, the selected week date will be sent to the server as a string in the YYYY-Www
format.
The <input type="week">
element is supported by most modern browsers, including Chrome, Firefox, Safari, and Edge. However, it is not supported by Internet Explorer or older versions of Safari.
The <input type="week">
element is a useful input type for forms that require the user to select a week date. It is easy to use and supported by most modern browsers. However, be aware of its limited browser support and consider providing a fallback option for older browsers.