modiX modiX - 8 months ago 56
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?


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