Javascript DOM HTML Input Week value Property set

Introduction

Set the week and year for a week field:

document.getElementById("myWeek").value = "2014-W48";

Click the button to set a week and year for the week field.</p>

input elements with type="week" are not supported in Internet Explorer or Firefox.

View in separate window

<!DOCTYPE html>
<html>
<body>

Week and Year: <input type="week" id="myWeek">

<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {//w  ww.j ava 2 s. co m
  document.getElementById("myWeek").value = "2014-W48";
}
</script>

</body>
</html>

The value property sets or gets the value attribute of a week field.

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

The <input type="week"> element is not supported in Firefox.

Value
Description
YYYY-WWW Specifies the week and year.
Explanation of components:
YYYY - year (e.g. 2020) The literal string "-W" indicates "week"
WW - week (in the range of 1 to 52 or 53, e.g. 01 for the first week of the year)
Example: 2014-W15
Return Value: A String, representing the year and week of the week field



PreviousNext

Related