How to set default value to the input[type="date"]

hh54188 picture hh54188 · Jan 8, 2013 · Viewed 466.2k times · Source

I have tried (JSFiddle):

<input type="date" value="2012-3-23">

but it doesn't work, how can I set the default value?

Answer

Lewis Norton picture Lewis Norton · Jan 8, 2013

The date should take the format YYYY-MM-DD. Single digit days and months should be padded with a 0. January is 01.

From the documentation:

A string representing a date.

Value: A valid full-date as defined in [RFC 3339], with the additional qualification that the year component is four or more digits representing a number greater than 0.

Your code should be altered to:

<input type="date" value="2013-01-08">

Example jsfiddle