Skip to content

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
Discussion options

You must be logged in to vote
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`    
 ta…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by usmankhan495
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants