Feature detect date
by abhitalks
HTML
<input id="dated" type="text" />
<input id="dated2" type="date" />
JavaScript
var dtType;
// We know this is text type so attaching datepicker
$("#dated").datepicker({ dateFormat: 'yy-dd-mm' });
// We check the type of the second element
dtType = document.getElementById("dated2").type;
/*
If the browser supports html5 date type,
then it will return "date".
If browser doesn't support,
it will default to "text" type.
*/
if (dtType == "text") {
// Attach datepicker only if type is "text"
$("#dated2").datepicker();
}