modiX modiX - 1 year ago 112
HTML Question

Detecting input type support of date and datetime types?

I try to use Modernizr to detect the support for

input fields (HTML5), but those variables always return
, even when they are supported (i.e. in Chrome):

if(Modernizr.inputtypes.datetime) {
jQuery("#what").html("Yes, I know datetime input fields.");
} else {
jQuery("#what").html("Sorry, what is a datetime input field?");

#what {
padding : 2em;
margin : 2em;
text-align : center;

border : 1px solid #000;

<script src=""></script>
<script src=""></script>
<div id="what">Well... I'm not sure.</div>

By researching this problem it seems this bug is an old habit.

How can I solve it?

Answer Source

datetime is not supported on chrome or firefox.

For future ref you can use:

EDIT Use Modernizr.inputtypes['datetime-local'] or Modernizr.inputtypes['date'] instead

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download