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.

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
Post a Comment