I'm using this lib in my app:
https://reactdatepicker.com/
There is an excludeDates prop which I can use, where I can pass a list of dates aka this would exclude today and yesterday:
excludeDates={[moment(), moment().subtract(1, "days")]}
I would prefer to have a better way than passing however many hundreds of dates into that array though.
Thanks!
To disable the past and future dates, we have to use the isValidDate property of the react-datetime.
Disable input DateRangePicker allows date and time input via keyboard by default, if you wish to disable it, you can disable editing by setting editable={false} .
To disable the dates, we have to use the isValidDate property of the react-datetime. As per the documentation, isValidDate is the function and by default is returning the true value.
Maybe you can use the component like that:
<DatePicker
selected={this.state.startDate}
onChange={this.handleChange}
minDate={moment().toDate()}
placeholderText="Select a day"
/>
You can use minDate and maxDate props to select a unique range of date selectable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With