Detect change to selected date with bootstrap-datepicker

All others answers are related to jQuery UI datepicker, but the question is about bootstrap-datepicker. You can use the on changeDate event to trigger a change event on the related input, and then handle both ways of changing the date from the onChange handler: changeDate Fired when the date is changed. Example: $(‘#dp3’).datepicker().on(‘changeDate’, function (ev) … Read more

jQuery ui datepicker conflict with bootstrap datepicker

This issue can be solved using the noConflict method of bootstrap-datepicker $.fn.datepicker.noConflict = function(){ $.fn.datepicker = old; return this; }; You can just do $.fn.datepicker.noConflict() which replaces the bootstrap datepicker with the older datepicker which was present, in this case jQuery UI. For those who wants to keep both datepickers, you can do something along … Read more

Limit bootstrap-datepicker to weekdays only?

The latest version from https://github.com/eternicode/bootstrap-datepicker already has an option to disable selection of particular weekdays. From the docs: daysOfWeekDisabled String, Array. Default: ‘’, [] Days of the week that should be disabled. Values are 0 (Sunday) to 6 (Saturday). Multiple values should be comma-separated. Example: disable weekends: ‘0,6’ or [0,6]. In other words, just instantiate … Read more

Sort a string date array

The Simple Solution There is no need to convert Strings to Dates or use RegExp. The simple solution is to use the Array.sort() method. The sort function sets the date format to YYYYMMDD and then compares the string value. Assumes date input is in format DD/MM/YYYY. data.sort(function(a,b) { a = a.split(“https://stackoverflow.com/”).reverse().join(”); b = b.split(“https://stackoverflow.com/”).reverse().join(”); return … Read more

How to restrict the selectable date ranges in Bootstrap Datepicker?

The Bootstrap datepicker is able to set date-range. But it is not available in the initial release/Master Branch. Check the branch as ‘range’ there (or just see at https://github.com/eternicode/bootstrap-datepicker), you can do it simply with startDate and endDate. Example: $(‘#datepicker’).datepicker({ startDate: ‘-2m’, endDate: ‘+2d’ });