Summary -
In this topic, we described about the Week Input type with detailed example.
Week input type accepts the user to choose week and year from the date picker drop-down.
Syntax -
<input id="vacation" name="vacation" type="week">
Example -
Below example explains the select week from the date picker drop-down.
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML5 Week Input Type</title>
<script>
function getValue() {
var week = document.getElementById("myweek").value;
alert(week);
}
</script>
</head>
<body>
<form>
<label for="myweek">Choose Week:</label>
<input type="week" id="myweek">
<button type="button" onclick="getValue();">Get Value</button>
</form>
</body>
</html>
Output-
Warning:The input type="week" is not supported by Safari, Firefox, and Internet Explorer browsers. Presently backed by Edge, Chrome, and Opera browsers.
Browser Support
The following browsers and corresponding versions in the table that completely supports the week type.
Input Type | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Type="week" | 25.0 | 12.0 | Not Supported | Not Supported | 10.1 |