Problem for spaced dates

Hi Omar:

I think I understand now.

What you are saying is that when the date for recovery (collection) is selected then you want to automatically set the date for delivery to be two days later.

So if the customer chooses Lundi then you want to offer delivery starting on or after Mecredi.

If this is the case then I would disable $w(" #datePicker2 “) using $w(” #datePicker2 “).disable(); in your $w.onReady() function. Then wait for the customer to change the value of $w(” #datePicker 1") using the onChange handler. In the onChange handler I would enable the delivery datepicker and use the selected date from $w(" #datePicker 1") to configure datepicker 2

$w.onReady(() => {
    $w("#datePicker2").disable(); // Don't allow input until the collection date is set
    $w("#datePicker1").minDate = addDays(Date.now(), 0); // We can collect from today
    
    // When a collection date is set we can enable the delivery date
    $w("#datePicker1").onChange((event) => {
        let baselineDate = $w("#datePicker1").value;
        $w("#datePicker2").minDate = addDays(baselineDate.valueOf(), 2);
        $w("#datePicker2").enable();
    }
});

function addDays(baselineDate, days) {
    return new Date(baselineDate + days*24*60*60*1000);
}

I don’t think you need to worry about setting the maxDate value.

Hope this helps
Steve