javascript - Native datepicker on Chrome and fallback for IE/Firefox -


along html5 came new set of input types. 1 of these date , in chrome input produces nice native date picker 1 shown below.

datepicker

it provides native date pickers on mobile devices main strong point using new input type.

however, on firefox (23.0.1) , ie (10), native date picker doesn't appear , input treated normal text input. it's in these cases want fall javascript date picker.

the site runs angularjs , current datepicker plugin bootstrap-datepicker. what's easiest way me disable plugin if browser supports native date pickers? need check if browser supports date input type , disable plugin if that's case?

you can html5 feature check so:

// determine if browser supports date input type. var datesupported = (function() {     var el = document.createelement('input'),         invalidval = 'foo'; // value not date     el.setattribute('type','date');     el.setattribute('value', invalidval);     // supported browser modify if true date field     return el.value !== invalidval; }()); 

then initialize bootstrap datepicker if !datesupported.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

Git submodule update: reference is not a tree... but commit IS there -