2

I'm using this date picker component and I'm using the 'disablePast' prop. This means that on the calendar they're greyed out and cannot be selected. How can you make it so that you can create an alert or popup when you try and click on any of the disabled days (past dates). Thanks!

<DatePicker
          inputVariant='outlined'
          disableToolbar
          format='dd/MM/yyyy'
          margin='normal'
          id='Select-Start-Date'
          label='Select Start Date'
          value={selectedStartDate}
          onChange={handleStartDateChange}
          inputProps={{ style: { textAlign: 'center' } }
          disablePast

        />
2
  • 1
    You can take a use of shouldDisableDate function and check if the date is from the past then can alert or show popup Nov 19, 2019 at 11:00
  • I'd like it so you're able to click a greyed out date and then something happens. Trying to figure out the best way to do that.
    – J. Doe
    Nov 19, 2019 at 13:57

1 Answer 1

1

either fork that lib to add the functionality you need or use a dirty hook like noticing what class is added to the disabled dates and adding a click listeners to the document which checks if click was in those class objects area

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.