react-multi-date-picker icon indicating copy to clipboard operation
react-multi-date-picker copied to clipboard

Limit number of selected date ranges

Open porlov opened this issue 1 year ago • 1 comments

Hello,

I'm using range and multiple props enabled.

Is there some way to limit number of selected date ranges? So, for example, if the maximum number of allowed date ranges is 2, and user selected two ranges and tries to select a new one, the 2nd range should be substituted instead of selecting of 3rd range.

Do you have any idea?

porlov avatar Feb 27 '24 17:02 porlov

Hello. Have you tried validating the selected dates in the onChange method? You can prevent the selected dates from being set by returning false in the onChange method: https://shahabyazdi.github.io/react-multi-date-picker/validation/#validating-range-of-dates

shahabyazdi avatar May 18 '24 10:05 shahabyazdi