Skip Navigation

[Closed] Link 2 Date/Time Fields So 2nd Date Can't Be Before 1st Date

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Beda 6 years, 1 month ago.

Assigned support staff: Beda.


I have quite a few situations where I have to set up a "start date/time" and an "end date/time". It's frustrating for the users, especially when choosing dates at least a few months into the future, to have to choose a date from the "start date" field, then have to start all over again when choosing the "end date".

It would be nice if there was a simple way to link two date/time fields so that the 2nd date automatically sets itself to the value of the 1st date when someone chooses the 1st date, and disables any dates in the 2nd date picker that fall before the 1st date.

Essentially, here's the workflow I imagine:

1. User opens the date picker for "start date" and chooses 12/25/2016.
2. "End date" field automatically sets itself to 12/25/2016
3. User opens "end date" date picker and can only choose dates on or after 12/25/2016. If they try to choose 12/25/2015 or something like that, they will be unable to do so, as those will be disabled.

You see this type of functionality quite often on many different websites (for instance, when trying to reserve a hotel room), and you also see this in a lot of interfaces within various WordPress plugins (for instance, any event-based plugin). It would be nice to be able to set up that sort of set of fields in Types to be used on the backend.

I'm not sure whether this would be a new type of field altogether ("date range" or something), or if there would simply be an option to connect two existing date/time fields to say that they represent a range, but it would be nice to see this functionality in Types either way. Thanks.


Thank you for contacting us here in the Support Forum

To do this as a "default" option in CRED, a new field and API would be required.

I can file this request for you if you wish.

Meanwhile you can try a Custom JS, which you use on the given CRED form.

As a example:

$('#date').datepicker('option', 'minDate', new Date(startDate));
$('#date').datepicker('option', 'maxDate', new Date(endDate));

Please let me know if you need further infos about this.

Thank you for your patience.

The topic ‘[Closed] Link 2 Date/Time Fields So 2nd Date Can't Be Before 1st Date’ is closed to new replies.