Disable certain time slot

Home Forums Quform WordPress Disable certain time slot

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

    Hi, I’m trying to disable the time slots during lunch.

    Found some code on here to assign specific time slots each day but tbh I just like to remove 12:00 12:30 and 13:00 from each day.

    Currently have this, which does the trick somewhat, but you can still select those times and then change the date after. (the 12:00, 12:30 and 13:00 only get removed from the list if you select a date first)

    Is there an easier solution?

    jQuery(function ($) {
        var datepicker = $('.quform-field-6_27').data('kendoDatePicker'),
            timepicker = $('.quform-field-6_28').data('kendoTimePicker');
    
        if (window.kendo && datepicker && timepicker) {
            datepicker.setOptions({
                change: function () {
                    var date = datepicker.value();
    
                    if (date) {
                        var dayOfWeek = date.getDay(),
                            times = [
                                '08:00', '08:30', '09:00', '09:30', '10:00',
                                '10:30', '11:00', '11:30', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30', '18:00',  '18:30', '19:00', '19:30', '20:00'  
                            ];
    
                        if (dayOfWeek === 0) { // Sun
                            times = [];
                        } else if (dayOfWeek === 1) { // Mon
                            times = [
                                '08:00', '08:30', '09:00', '09:30', '10:00',
                                '10:30', '11:00', '11:30', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30', '18:00',  '18:30', '19:00', '19:30', '20:00'  
                            ];
                        } else if (dayOfWeek === 2) { // Tue
                            times = [
                                '08:00', '08:30', '09:00', '09:30', '10:00',
                                '10:30', '11:00', '11:30', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30', '18:00',  '18:30', '19:00', '19:30', '20:00'  
                            ];
                        } else if (dayOfWeek === 3) { // Wed
                            times = [
                                '08:00', '08:30', '09:00', '09:30', '10:00',
                                '10:30', '11:00', '11:30', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30', '18:00',  '18:30', '19:00', '19:30', '20:00'  
                            ];
                        } else if (dayOfWeek === 4) { // Thu
                            times = [
                                '08:00', '08:30', '09:00', '09:30', '10:00',
                                '10:30', '11:00', '11:30', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30', '18:00',  '18:30', '19:00', '19:30', '20:00'  
                            ];
                        } else if (dayOfWeek === 5) { // Fri
                            times = [
                                '08:00', '08:30', '09:00', '09:30', '10:00',
                                '10:30', '11:00', '11:30', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30', '18:00',  '18:30', '19:00', '19:30', '20:00'  
                            ];
                        } else if (dayOfWeek === 6) { // Sat
                            times = [
                                '08:00', '08:30', '09:00', '09:30', '10:00',
                                '10:30', '11:00', '11:30', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30', '18:00',  '18:30', '19:00', '19:30', '20:00'  
                            ];
                        }
    
                        var dates = [],
                            i = 0,
                            length = times.length,
                            d;
    
                        for ( ; i < length; i++) {
                            d = kendo.parseDate(times[i]);
    
                            if (d instanceof Date) {
                                dates.push(d);
                            }
                        }
    
                        timepicker.setOptions({ dates: dates });
                    }
                }
            });
        }
    });
    #31753
    Mobisolar
    Participant

    Can I get a reply on this? 🙂

    #31756
    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.

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