Feature detect date

by abhitalks

HTML

<input id="dated" type="text" />
<input id="dated2" type="date" />

JavaScript

var dtType,
    $inputs = $('input');

$inputs.each(function() {
    /*
    We check the type of each element.
    If the browser supports html5 date type,
    then it will return "date".
    If browser doesn't support, 
    it will default to "text" type.
    */
    dtType = this.type;
    if (dtType == "text") {
        // Attach datepicker only if type is "text"
        $(this).datepicker();
    }    
});