Home › Forums › Quform WordPress › Exclude date from an exclude list.
This topic is: resolved
- This topic has 2 replies, 2 voices, and was last updated 7 years, 9 months ago by
Legin76.
Viewing 3 posts - 1 through 3 (of 3 total)
- AuthorPosts
- November 28, 2017 at 6:43 pm #23246
Legin76
ParticipantI’ve set up a date field to exclude all days except Saturdays and Sundays. I have an exception for the 1st of January 18, which we would like users to be able to select, despite it being a Monday.
The code I’ve used is as follows.
function my_datepicker_block_days($options, $dpMinYear, $dpMaxYear, $element) { return "{ beforeShowDay: function (date) { var day = date.getDay(); if (day == 1 || day == 2 || day == 3 || day == 4 || day == 5) { return [false, '']; } else { return [true, '']; } } }"; } add_filter('iphorm_datepicker_options_iphorm_1_3', 'my_datepicker_block_days', 10, 4); add_filter('iphorm_datepicker_options_iphorm_4_3', '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 == 1 || $day == 2 || $day == 3 || $day == 4 || $day == 5) { $element->addError('Please choose a Saturday or Sunday'); $valid = false; } } return $valid; } add_filter('iphorm_element_valid_iphorm_1_3', 'my_block_days', 10, 3); add_filter('iphorm_element_valid_iphorm_4_3', 'my_block_days', 10, 3);
November 29, 2017 at 11:05 am #23264Ally
Support StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
November 29, 2017 at 5:09 pm #23270Legin76
ParticipantThat’s worked great.. Thank you.
- AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.