Skip to content

Instantly share code, notes, and snippets.

@surferxo3
Created December 18, 2018 07:17
Show Gist options
  • Save surferxo3/651623ed4c4990c811627836ec484f5f to your computer and use it in GitHub Desktop.
Save surferxo3/651623ed4c4990c811627836ec484f5f to your computer and use it in GitHub Desktop.
Enable specific dates in bootstrap datepicker widget
/*
Create case: you want to enable only the future dates and disable the past
Update case: you still want to enable future dates but enable only the the past date already stored in the db
*/
var now = moment(moment().format('DD/MM/YYYY'), 'DD/MM/YYYY');
$('#bulk-sms-form #start_date').datepicker({
format: 'dd/mm/yyyy',
beforeShowDay: function(date) {
var current = moment(date);
return current.isSame(moment('{{$messageConfig->start_date}}')) || current.isSameOrAfter(now);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment