I’ve two date pickers From
and To
Requirement:
From : Months <= 12PastMonthsFromNow should be DISABLE
To : Months > MonthsFromNow should be DISABLE
Only enable past 12 months from now.
Example:
From To
Apr-2022 Mar-2023 [Correct]
Mar-2022 Mar-2023 [In Correct]
CODES: https://codesandbox.io/s/flatpicker-with-current-time-forked-7j9yxs?file=/src/flatPicker.tsx
I have successfully achieved this using minDate
and maxDate
.
PROBLEM: FromDate
not displayed on load with minDate
configured.
If commented // minDate: moment(new Date()).subtract(11, "month").toISOString()
fromDate data shows up.
options={{
enableTime: false,
dateFormat: "M-Y",
altFormat: "M-Y",
maxDate: new Date().toISOString()
// minDate: moment(new Date()).subtract(11, "month").toISOString()
//FromDate shows data if minDate is commented
}}