Need to focus datepicker based on user input

We’ve created a contact form that allows visitors to enter check-in and check-out dates using two datepickers. We’d therefore like the user to select a date on the 1st datepicker (check-in) and then display results on the 2nd datepicker (check-out) that are only after the date inserted on the 1st one.

Although right now the logic works and the date on 2nd datepicker is a later date of the one of the 1st datepicker, the 2nd datepicker by default focuses on the current month and not on the one relevant month to the user’s input on the 1st datepicker.

The code used is the following:

import {processEnquiry, createEnquiry} from ‘backend/enquirySubmitLogic’;
$w.onReady(function () {

$w(‘#datePicker1’).onChange(()=>{
let pickerMinDate = $w(“#datePicker1”).value;
pickerMinDate.setDate(pickerMinDate.getDate()+1)
$w(“#datePicker2”).minDate = pickerMinDate;
});

You can set the “value” of the second datePicker to the same value as the “minDate” and it will open focused on that date.

Thank you for following up. Got it to work!

Hi @contact60. I know you posted this in 2018 and not sure if you are still in this forum, but I am trying to do the same think you initially asked about - set the focus of a datepicker (#eventEndDate) based on user input from another datepicker (#eventStartDate), rather than defaulting the focus to the current month. How did you resolve this? Thanks!