Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input Date value attribute

Input Date value attribute

Input Date Object Reference Input Date Object

Example

Set the date of the date field:

document.getElementById("myDate").value = "2014-02-09";

Try it »


Definition and Usage

The value attribute is used to set or return the value of the date field's value attribute.

The value attribute describes the date of the date field.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the value attribute

**Note:** Internet Explorer or Firefox browser does not support .


Syntax

Return the value attribute:

inputdateObject

.value

Set the value attribute:

inputdateObject

.value=

YYYY-MM-DD

Attribute values

Value Description
YYYY-MM-DD Specify the date of the date field.
 说明:     
  • YYYY - year (e.g.: 2011)
  • MM - month (e.g.: 01 for January)
  • DD - day (e.g.: 08)
  • Example: "2014-02-09". |

    Technical Details

    Return Value: A string representing the date of the date field.

    More examples

    Example

    Get the date of the date field:

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

    x

    The output is:

    2000-05-05

    Try it »


    Related pages

    HTML Reference Manual: HTML value attribute


    Input Date Object Reference Input Date Object