0

I am using Ant Design Calendar in my React project and I want to disable all the dates before today so that the user cannot select it.

The Calendar component looks like -

<Calendar
  fullscreen={false}
  onPanelChange={this._onPanelChange}
  onSelect={this._onDateSelect}
  disabledDate={() => }
/>

The Calendar API says we need to add disabledDate (which returns a boolean) in order to specify that using momentjs.

What should the query look like in moment.js?

Thanks in advance.

vaibhav deep
  • 655
  • 1
  • 8
  • 27
  • Does [this](https://stackoverflow.com/questions/53444495/reactjs-ant-design-disable-dates-less-than-any-default-date-in-datepicker/53445679) answer your question ? – Sayog Apr 07 '21 at 04:59
  • The demo doesn't seem to work. I can still select previous dates – vaibhav deep Apr 07 '21 at 05:06
  • Check [This](https://codesandbox.io/s/elegant-beaver-fl6hw) is working perfectly. – Sayog Apr 07 '21 at 05:39

1 Answers1

0

I use disabledDate in rangePicker .

 disabledDate={(current) => {
return 
   current && current && current < moment().subtract(1, "days") || 
    current >= moment(Date.now()).add(rangepickerlimitmonth, 'month');
                      }}

tell me to delete this answer if doesn't work.

rangepickerlimitmonthis a number I used to limit date in future which user can't select.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Able Jhon
  • 1
  • 2