Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6295

Disable Past and Future Dates using React-FlatPicker

$
0
0

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        }}

enter image description herePlease help.


Viewing all articles
Browse latest Browse all 6295

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>