qodesmith / datepicker

Get a date with JavaScript! A datepicker with no dependencies.
344 stars 101 forks source link

Feature Request: disableIfDateIsSupported #53

Closed sfusato closed 5 years ago

sfusato commented 5 years ago

This would be similar to the already existing disableMobile, but it would disable the plugin if the browser natively supports the type="date" field of an input.

Basically, the plugin will become just a fallback in case the browser doesn't have a native date picker solution.

Possible code for checking if the browser supports type="date":

var isDateInputSupported = function(){
var elem = document.createElement('input');
elem.setAttribute('type','date');
elem.value = 'foo';
return (elem.type == 'date' && elem.value != 'foo');
}

if (!isDateInputSupported())  // or.. !Modernizr.inputtypes.date
  $('input[type="date"]').datepicker();

Source: https://developers.google.com/web/updates/2012/08/Quick-FAQs-on-input-type-date-in-Google-Chrome

Would you consider a PR for this?

qodesmith commented 5 years ago

This feels like logic that should reside in the users code as opposed to an addition on the library.