Using the Bootstrap Datepicker, I'm trying to enable users to choose only first and third Wednesdays of each month.
For now, the only thing I've managed to do is to enable only Wednesdays, by passing it in the options. Does anyone know if I can pass my "first and third" wanted configuration as an option, and how?
<script type="text/javascript">
$(function () {
$('.bootstrap-date-picker').datetimepicker({
locale: 'fr',
daysOfWeekDisabled: [0,1,2,4,5,6],
format: "ll",
minDate: moment(),
icons:
});
});
</script>
You can use
enabledDates
option to enable single dates instead ofdaysOfWeekDisabled
.You can create an helper function that returns an array with the first and the third Wednesday of a given month using momentjs. An example can be found here.
You can add a listner for
dp.update
to update your enabled dates (usingenabledDates
function) when the user changes month.Here a complete working example:
Added
startOf('day')
inminDate
option to prevent problem when the current date is the first Wednesday of the month and you try to select it.