Tagged: datepicker, disable, exception
-
AuthorPosts
-
January 20, 2017 at 9:33 am #736302January 25, 2017 at 6:39 am #738133
Hey lijndiensten!
Thank you for using Enfold.
Please replace the snippet with the following code.
beforeShowDay: function(date) { var day = date.getDay(); if (date.getDate() == 14 && date.getMonth() == 1) { return [true, ""]; } return [(day != 2)]; },
Regards,
IsmaelJanuary 25, 2017 at 9:00 am #738199Magnificent, thanks Ismael.
As maybe a helpful reference to others, the total piece of code is as follows, allowing to disable given weekdays, make exceptions on those, and disable special dates (say, Christmas).
beforeShowDay: function(date) { var day = date.getDay(); if (date.getDate() == 14 && date.getMonth() == 1) { return [true, ""]; } function IsClosed(date) { var day = date.getDate(); var month = date.getMonth() + 1; return (day === 24 && month === 12) + (day === 25 && month === 12) + (day === 1 && month === 1) + (day === 2 && month === 1); } return [(day != 2 && !IsClosed(date))]; },
January 25, 2017 at 10:57 am #738263Hey!
Thank you for sharing that as a reference.
We do hope it will help someone at the end.Thanks a lot
Best regards,
BasilisJuly 29, 2023 at 12:56 am #1414791This also works with years:
beforeShowDay: function(date) { var day = date.getDay(); function IsClosed(date) { var day = date.getDate(); var month = date.getMonth() + 1; var year = date.getFullYear(); return (day === 25 && month === 12 && year === 2023)+(day === 24 && month === 12 && year === 2024); } return [(!IsClosed(date))]; },
July 29, 2023 at 11:28 am #1414804July 30, 2023 at 3:37 pm #1414921one thing to mention on inserting these snippets to child-theme functions.php: Sometimes you had to set the priority of the function to be before loading of datepicker. So a 10 might be usefull as priority – f.e.:
function exclude_datepicker_dates() { ?> <script type="text/javascript"> var unavailableDates = ["17/12/2017", "12/12/2017", "18/6/2017"]; function unavailable(date) { dmy = date.getDate() + "/" + (date.getMonth() + 1) + "/" + date.getFullYear(); if (jQuery.inArray(dmy, unavailableDates) == -1) { return [true, ""]; } else { return [false, "", "Unavailable"]; } } </script> <?php } add_action('wp_footer', 'exclude_datepicker_dates', 10);
and to keep in mind – counting starts at zero : Sunday is Day: 0 of the week and
-
AuthorPosts
- The topic ‘Disable all Tuesdays, except some in datepicker’ is closed to new replies.