Date picker – Block weekend — Old one doesn’t work anymore.

Home Forums Quform WordPress Date picker – Block weekend — Old one doesn’t work anymore.

This topic is: resolved
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #31542
    Mobisolar
    Participant

    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 3 years, 10 months ago by Mobisolar.
    #31548
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #31559
    Mobisolar
    Participant

    Using 2.x

    worked like a charm this time. thanks

    • This reply was modified 3 years, 10 months ago by Mobisolar.
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy