react-datetime-picker icon indicating copy to clipboard operation
react-datetime-picker copied to clipboard

Trigger onChange when date is not valid

Open agustingazzano opened this issue 4 years ago • 3 comments
trafficstars

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.

agustingazzano avatar May 26 '21 12:05 agustingazzano

@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.

foscjos2 avatar Oct 12 '21 21:10 foscjos2

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

foscjos2 avatar Oct 12 '21 21:10 foscjos2

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.

cjmaria avatar Aug 22 '22 00:08 cjmaria

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.

github-actions[bot] avatar Dec 05 '22 00:12 github-actions[bot]

This issue was closed because it has been stalled for 14 days with no activity.

github-actions[bot] avatar Dec 26 '22 00:12 github-actions[bot]