-3

How to set the default date in html5 date element

<input type="date" min="1940-01-01" max="2012-12-31" id="datepicker" name="mybirthday" placeholder="Birthdate(MM/DD/YYYY)" />

The default date is set to 2012-12-31. How to change that?

Aravind Bharathy
  • 1,540
  • 3
  • 15
  • 32

2 Answers2

0

Set the value attribute:

<input type="date" value="1940-01-01" />
Matt Cain
  • 5,638
  • 3
  • 36
  • 45
0

Just add a value attribute. e.g. value="2011-06-15"

<input type="date" min="1940-01-01" max="2012-12-31" id="datepicker" name="mybirthday" placeholder="Birthdate(MM/DD/YYYY)"  value="2011-06-15" />
harryg
  • 23,311
  • 45
  • 125
  • 198
  • I tried that. But in chrome when i click on the date picker it is not pointing to the desired value – Aravind Bharathy Jun 25 '13 at 08:31
  • No it will prefill the date box with the `value` attribute. The interface is determined by the browser. If you want more control over the datepicker consider using a framework like [jQuery UI](http://jqueryui.com/datepicker/) or a [bootstrap plugin](http://www.eyecon.ro/bootstrap-datepicker/) – harryg Jun 25 '13 at 10:03