I have created a custom form for scheduling requests. Users can click the day they want an appointment. They can do same day requests but up to a certain time. How can I disable the current day on a date picker at a specific time of day? (Example: No same day appointment requests can be done after 8:00am.)
Using Wix Editor - This is the code I have tried:
let myDatePicker = $w('#datePicker1');
let today = new Date();
function isTimeWithinRange(startTime, endTime) {
const currentHour = new Date().getHours();
const currentMinute = new Date().getMinutes();
return currentHour >= startTime && currentHour < endTime (currentHour === startTime && currentMinute >= 0)(currentHour === endTime && currentMinute < 60);
}
function updateDatePickerState() {
let disableDatePicker = isTimeWithinRange(8, 16);
if (disableDatePicker) {
myDatePicker.disabledDateRanges = [new Date()];
} else {
myDatePicker.disabledDateRanges = [];
}
}
$w.onReady(() => updateDatePickerState());
I am getting the error “Type ‘Date’ is missing the following properties from type ‘DateRange’: startDate, endDate” on line 12 for [new Date()];
I am pretty beginner at coding and know enough to cause some trouble Hoping someone could help find a solution or offer another suggestion to implement time of day date disabling. Thank you SO much for any help!