Buy Now
Sign in

Two datepickers -> use first date as startdate for second date

jj135 , November 08 2017
jj135
Hi! When I use two datepickers in a form, one for a startdate of an event and one for an end date of an event, how do I get the second datepicker popup to start on the selected date of the first datepicker field?

So:

FIELD1 (datepicker) : User enters this value: 01-01-2019
FIELD2 (datepicker): user clicks on field and popup shows the '01-01-2019' as starting date.

This ensures the user does not have to browse twice to find a date in the future.

I tried setting the value of 'endcalendar' in the first date field to the ID of the second field. And setting the 'startcalendar' tot the ID of the first field in the second date field. But that did not seem to do the trick...

Is it also possible to validate the second (end) date as being AFTER the first date?

Kind regards,
Jip
jj135
I got it working. Not sure what I did, but maybe there was a caching issue while testing the site. I did exactly what I described above: Setting the field ID of the second date field as 'endcalendar. And in the seconf (end) date field I set 'startcalendar' to the ID of the first date field.

This question remains:

Is it possible to validate (javascript) the second (end) date as being AFTER the first date filed (value)?
H
hwsassisi
I have to make the same form, with check-in and check-out dates.
Obviously check-in date starts from tomorrow and check-out date must be at least one day after check-in date.
In checkInCalendar, set #checkOutCalendar in "End Calendar" advanced field
In checkOutCalendar, set #checkInCalendar in "Start Calendar" advanced field
But, in this case, checkOutCalendar accepts the same date the checkInCalendar.
How is possible to force checkOutCalendar to start 1 day after checkInCalendar?
Regards
admin
Hi,
Maybe you will need some custom js validation function for this, after the date is selected you can parse it and check if its the same date or not.
Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!