For a mobile html5/js website I would like to leverage native browser date/time pickers when available (like on mobile safari for instance). I know I can detect if the browser supports the date/datetime input types, which will help ensure the proper data format is entered, but is there a proper way to detect if the current browser offers native date and/or time picker?
For a mobile html5/js website I would like to leverage native browser date/time pickers when available (like on mobile safari for instance). I know I can detect if the browser supports the date/datetime input types, which will help ensure the proper data format is entered, but is there a proper way to detect if the current browser offers native date and/or time picker?
Share Improve this question asked Oct 23, 2012 at 7:01 RomainRomain 1,3021 gold badge10 silver badges14 bronze badges1 Answer
Reset to default 8you can create an input element and try to assign the type, if it's not supported the type will switch back to the default type (which is text)
function isDateSupported() {
var i = document.createElement("input");
i.setAttribute("type", "date");
return i.type !== "text";
}
or you can use a tool like modernizr