Dynamically add jQuery multidatepicker "addDisabledDates" property

I am using jQuery multi datepicker in my html. I need to change the setting property of the date picker dynamically, i.e. When I select the “normal” option in the selection box, I turn off “Saturday” and “Sunday” in my calendar, and when I select the “custom” option in the selection box, I turn off my user days. I do not know how to specify in my code. This is my code.

$('#datePick').multiDatesPicker({ beforeShowDay: disableSpecificWeekDays, // For disabling all "Sundays" dateFormat: "d/m/yy", maxDate: "+3m", minDate: "-1m", multidate: true, addDisabledDates: my_array }); function disableSpecificWeekDays(date) { var theday = date.getDate() + '/' +(date.getMonth() + 1) + '/' + date.getFullYear(); var day = date.getDay(); return [day != 0 && day != 6]; } 

Please help me post it?

+5
source share
1 answer

Assuming you have a drop down menu:

 <select id="my-dropdown"> <option value="normal">normal</option> <option value="custom">custom</option> </select> 

Then you just need to:

 function disableSpecificWeekDays(date) { if ($('#my-dropdown').val() == 'normal') { return [true]; } var theday = date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear(); var day = date.getDay(); return [day != 0 && day != 6]; } 
+2
source

Source: https://habr.com/ru/post/1258815/


All Articles