Input Date value Attribute
Definition and Usage
value
Sets or returns the value of the value attribute of the date field.
The HTML value attribute specifies the date of the date field.
See Also:
HTML Reference Manual:HTML <input> value Attribute
Instance
Example 1
Set the date for the date field:
document.getElementById("myDate").value = "2023-02-15";
Example 2
Get the date of the date field:
var x = document.getElementById("myDate").value;
Example 3
An example showing the difference between the defaultValue and value attributes:
var x = document.getElementById("myDate"); var defaultVal = x.defaultValue; var currentVal = x.value;
Syntax
Return the value attribute:
inputdateObject.value
Set the value attribute:
inputdateObject.value = YYYY-MM-DD
Attribute Value
Value | Description |
---|---|
YYYY-MM-DD |
The date of the specified date field. Component Description:
For example: "2023-02-15" represents February 15, 2023 (15/02/2023). |
Technical Details
Return Value: | A string value representing the date of the date field. |
---|
Browser Support
The numbers in the table indicate the first browser version that fully supports this property.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |
Note:The <input type="date"> element does not display any date field/calendar in IE11 and earlier versions.