longbill / jquery-date-range-picker

A jQuery plugin that allows user to select a date range
MIT License
1.12k stars 579 forks source link

change only second date #461

Closed ghost closed 4 years ago

ghost commented 5 years ago

I tried a lot of methods but didn't work is there anyway we can only set the second date if it's greater than the first date.

monovertex commented 5 years ago

Hi, @peterbardawil. If I understand your issue correctly, you want your users to be able to only select dates forward? Please see example 38 which uses the selectForward option and let me know if it fixes your issue.

Notfallplan commented 5 years ago

Hi,

at first, happy new year to everyone :)

I think the question is not answered yet. I am also looking for a solution, as I understand the opener.

Example: We have already selected a date range, for example 2019/01/01 to 2019/02/02. Now we open the picker again and select the 2019/03/03.

The desired result would be a changed of the second(to) date to 2019/03/03.

Best, Christoph

monovertex commented 4 years ago

This seems a bit like weird UX in my opinion, but you can definitely use the datepicker-first-date-selected event to detect when the first date is changed, keep a copy of the previous selection somewhere and compare that to the current first date selected and set the second one if necessary.

I am closing this issue as answered, feel free to continue this thread if things are still not clear.