Input Week defaultValue property
Definition and usage
defaultValue
The property sets or returns the default value of the week field.
Note:The default value is HTML value attribute specified by
The difference between defaultValue and value properties is that defaultValue contains the default value, while value contains the current value after some changes. If there is no change, defaultValue and value are the same (see the example below).
The defaultValue property is very useful if you want to check whether the week in the week field has changed.
Instance
Example 1
Change the default value of the week field:
document.getElementById("myWeek").defaultValue = "2023-W01";
Example 2
Get the default value of the week field:
var x = document.getElementById("myWeek").defaultValue;
Example 3
Show the example of the difference between defaultValue and value properties:
var x = document.getElementById("myWeek"); var defaultVal = x.defaultValue; var currentVal = x.value;
Syntax
Return the defaultValue property:
weekObject.defaultValue
Set the defaultValue property:
weekObject.defaultValue = value
Attribute Value
Value | Description |
---|---|
value | Specifies the default value of the week field. |
Technical Details
Return Value: | A string value that represents the default value 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.