admin管理员组文章数量:1315353
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
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
Share Improve this question edited Jan 9, 2014 at 17:45 Rikard asked Jan 9, 2014 at 17:37 RikardRikard 7,80513 gold badges60 silver badges99 bronze badges 7- Change the option in the fiddle on the left from "onload", to "no-wrap in body", and it adds the attribute. – adeneo Commented Jan 9, 2014 at 17:40
-
@adeneo, no difference: jsfiddle/5UbPs/2 - and as I said, I see the
min="2013-12-9"
in the HTML, it just doesn't work... – Rikard Commented Jan 9, 2014 at 17:43 - This works for me on Chrome Version 32.0.1700.72 m – stackErr Commented Jan 9, 2014 at 17:44
- @stackErr, I'm using Version 31.0.1650.63 m. Do you get it to work out of the box with my fiddle? – Rikard Commented Jan 9, 2014 at 17:45
- @Rikard yeah in your fiddle...from the datepicker, everything before 2013-12-09 is grayed out. Though I can manually input any date I want – stackErr Commented Jan 9, 2014 at 17:47
1 Answer
Reset to default 6According to w3c (http://dev.w3/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/edgarinvillegas/5UbPs/9/
It works :)
Cheers, from La Paz, Bolivia
本文标签: htmlinput type date and min value set by javascriptStack Overflow
版权声明:本文标题:html - input type date and min value set by javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741976004a2408123.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论