Rikard
Rikard

Reputation: 7805

input type date and min value set by javascript

I am using Chrome (Version 31.0.1650.63 m), and when I set a min date on a input type date via javascript, the min attribute is changed in the HTML but the datepicker doesn't use it.

What am I missing?

<input type="date" id="input" />
//...
document.getElementById('input').setAttribute("min", '2013-12-9');

Fiddle

Upvotes: 3

Views: 10800

Answers (1)

Edgar Villegas Alvarado
Edgar Villegas Alvarado

Reputation: 18344

According to w3c (http://dev.w3.org/html5/markup/input.date.html) you just need leading zero in the day:

Instead of 2013-12-9

must be 2013-12-09

http://jsfiddle.net/edgarinvillegas/5UbPs/9/

It works :)

Cheers, from La Paz, Bolivia

Upvotes: 6

Related Questions