Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit number of selected date ranges #280

Open
porlov opened this issue Feb 27, 2024 · 1 comment
Open

Limit number of selected date ranges #280

porlov opened this issue Feb 27, 2024 · 1 comment

Comments

@porlov
Copy link

porlov commented Feb 27, 2024

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?

@shahabyazdi
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants