Home › Forums › Quform WordPress › Date picker – Block weekend — Old one doesn’t work anymore.
- This topic has 2 replies, 2 voices, and was last updated 4 years, 5 months ago by Mobisolar.
- AuthorPosts
- June 17, 2020 at 12:54 pm #31542MobisolarParticipant
Hi I have this Datepicker in the form where I want to disable the weekends. Love them to grey out and not be selectable at all. I used to have an Error message when people would submit but somehow it doesn’t work anymore.
‘function my_datepicker_block_days($options, $dpMinYear, $dpMaxYear, $element)
{
return “{
beforeShowDay: function (date) {
var day = date.getDay();
if (day == 0 || day == 6) {
// Zondag of Zaterdag uitgesloten
return [false, ”];
} else {
return [true, ”];
}
}
}”;
}
add_filter(‘iphorm_datepicker_options_6_27’, ‘my_datepicker_block_days’, 10, 4);function my_block_days($valid, $value, $element)
{
if ($valid) {
$time = strtotime(“{$value[‘year’]}-{$value[‘month’]}-{$value[‘day’]}”);
$day = date(‘w’, $time);if ($day == 0 || $day == 6) {
$element->addError(‘Afspraken kunnen niet in het weekend’);
$valid = false;
}
}return $valid;
}
add_filter(‘iphorm_element_valid_6_27, ‘my_block_days’, 10, 3);jQuery(function ($) {
var datepicker = $(‘.quform-field-6_27’).data(‘kendoDatePicker’);if (datepicker) {
datepicker.setOptions({
disableDates: function (date) {
return date && $.inArray(date.getDay(), [0, 6]) > -1
}
});
}
});’- This topic was modified 4 years, 5 months ago by Mobisolar.
June 18, 2020 at 10:48 am #31548AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
June 18, 2020 at 1:25 pm #31559 - AuthorPosts
- You must be logged in to reply to this topic.