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";

Try It Yourself

Example 2

Get the date of the date field:

var x = document.getElementById("myDate").value;

Try It Yourself

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;

Try It Yourself

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:

  • YYYY - The year (e.g., 2023)
  • MM - The month (e.g., 02 represents June)
  • DD - The day of the month (e.g., 15)

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.