react-datepicker disable auto adjust on invalid

53 Views Asked by At

My question is about the react-datepicker package.

Is there a way to turn off the automatic date reset by manually entering the date in the text field if the date is outside the minimum and / or maximum range?

Example: If I have set the maximum to 06.11.2023 and I enter 12.12.2023, the date is automatically set to 06.11.2023.

Unfortunately, I would like to display an error message saying that the maximum has been exceeded.

However, I cannot check this, as the field adjusts automatically and the onChange function won't get called. It only get called on a valid date input.

Btw I am using react-hook-form

Is there a way to switch off this function or display the error message in another way? At the moment I work around the problem by simply not entering a minimum and maximum date but still validating it via a function. However, it is possible to select days outside the minimum and maximum dates, which is not what I want.

0

There are 0 best solutions below