Is there a way to restrict users from choosing identical(Same) dates in a DateRangePicker? #3569
Answered
by
simonguo
usmankhan495
asked this question in
Q&A
Replies: 1 comment
-
import { DateRangePicker } from "rsuite";
import isSameDay from "date-fns/isSameDay";
<DateRangePicker
shouldDisableDate={(date, selectDate, selectedDone, target) => {
if (target === "CALENDAR" && selectedDone === false) {
if (isSameDay(date, selectDate[0])) {
return true;
}
}
return false;
}}
/> shouldDisableDate(
// Date used to determine if disabling is required.
date: Date,
// Date selected.
selectDate: Array<Date>,
// Whether to choose to finish now. If `false`, only the start date is selected, waiting for the selection end date.
selectedDone: boolean,
// Call the target of the `shouldDisableDate`
target: 'CALENDAR' | 'TOOLBAR_BUTTON_OK' | 'TOOLBAR_SHORTCUT' | 'INPUT',
) => boolean |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
usmankhan495
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there a way to restrict users from choosing identical(Same) dates in a DateRangePicker?
Beta Was this translation helpful? Give feedback.
All reactions