react-datetime-picker
react-datetime-picker copied to clipboard
Trigger onChange when date is not valid
At the moment there is no way of knowing if the current date is valid or not. If I want to use this component in a submittable form I need to know the date that is currently on the field and not the last valid date, which is what it does by default.
@wojtekmaj I am having the same issue, is there a workaround for this? Basically I want to be able to use OnChange to see if the user entered something invalid.
It seems like there is a PR open for this, is the functionality still something that is planned? https://github.com/wojtekmaj/react-datetime-picker/pull/104
That PR (which has been merged) seems to do something slightly different than what op is describing. While it prevents invalid datetimes from being returning in the onChange callback, it still allows room for the last selected datetime to be not what the user intended.
For instance, if I am entering a time of 8:98 PM, onChange will first call back with 8:09 because it parses the "9" in "98" as a single-digit time. When I proceed to hit 8, it will not trigger an onChange callback because 98 is an invalid minute value. However, if you are saving the time state using onChange, you will have inaccurately stored 8:09 and have no way of telling that this was part of an invalid time. This would require a separate onInvalid callback.
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.
This issue was closed because it has been stalled for 14 days with no activity.