Conditional Form - Disabling dropdown options based on #datepicker weekday choice.

The goal is to prevent the user from being able to submit the form if their date selection and dropdown selection (time in this case) do not match the rule. The rule is that you can’t choose a dropdown time option of 16:30 or earlier if your date selection is on a weekday.

You can see the form here: https://www.playbackottawa.ca/ag-pizza-form . The fields in question are the ‘Event Date’ (#datepicker1) and ‘Event Time’ (#dropdown7). I chose to use a dropdown over a time picker as it’s neater and I don’t need the time in a proper time format on the database.

I tried to prevent the submit button from working if the conditions were not met, but that didn’t work at all. I’m thinking that as the user chooses the date first, it might be easiest to remove the dropdown options before 16:30 if the user has selected a weekday on the datepicker.

If someone could point me in the right direction, or show a bit of code that could get me started on the easiest solution, I would be extremely grateful!

First of all: make the time dropdown disable by default.
Then create $w("#dateDropdown).onChange() function.
In side it add a condition:

if(new Date($w("#dateDropdown").value).getDay() === /*what day*/)
{$w("#timeDropdown").options = /*put here the options*/
}else{
$w("#timeDropdown").options = {/*put here the options*/}
} $w("#timeDropdown").enable();

and see documentation:
https://www.wix.com/corvid/reference/$w.Dropdown.html