Hi,
As the title says. I need the datepicker to only make the last friday of the month able to select. How do I do this?
Thanks!
Hey Abosict,
You might get an idea here
https://stackoverflow.com/questions/3805486/jquery-datepicker-only-select-mondays-and-thursdays
https://stackoverflow.com/questions/12061483/jquery-ui-datepicker-disable-all-days-except-first-and-15th-day-of-each-month
If you need further assistance please let us know.
Best regards,
Victoria
Thanks for you answer, I tried coding it, but I can’t get it to work. Also I don’t know where to put my code. Could you help me with the code, please?
if you are working with a child theme do this in your functions.php:
function determine_last_friday() {
?>
<script type="text/javascript">
function enableLastFriday(date) {
var lastDayInMonth = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
var isFriday = date.getDay() == 5;
var isLastDayOfMonth = date.getDate() > lastDayInMonth - 7;
return [isFriday && isLastDayOfMonth, ''];
}
</script>
<?php
}
add_action('wp_footer', 'determine_last_friday', 10);
function only_last_friday() {
?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery.datepicker.setDefaults({
beforeShowDay: enableLastFriday
});
});
</script>
<?php
}
add_action('wp_footer', 'only_last_friday', 20);
PPS: i had to splitt that functions- because i don’t want to override the enfold settings to datepicker template
see here in contact form element: https://webers-testseite.de/8-columns/
and by the way you can highlight that field by quick css:
#top .avia-datepicker-div td:not(.ui-datepicker-unselectable) a {
background-color: #0f0;
color: #000;
}
Hi,
Thanks for sharing and helping out @guenni007, did you try that out @abosict?
Best regards,
Rikard
You’re a hero! Thanks mr. Guenni!
Hi,
Glad @guenni007 was able to help, we will close this now. Thank you for using Enfold.
Best regards,
Mike