react-datetime-picker
react-datetime-picker copied to clipboard
Is there any way to prevent invalid values from being typed on hour/min/sec inputs?
For example, when user types "25" on hour input, can I prevent the number from being rendered on the input?
BTW, this project is AWESOME!
cc. @wojtekmaj
@wojtekmaj Any help would be appreciated.
Hi there, no, at the moment you cannot. We give the user visual feedback but the user has to correct the input on their own.
Looking at the behavior of native inputs, I think it should be done, though. I'll keep it on my list of potential enhancements.
I should also mention that the date has to be valid in order to be submitted via onChange, so you will never get an invalid date from the widget itself.
I see. Thank you!
@wojtekmaj Does your answer apply to react-time-picker as well, correct?
Yes, it does. To React-Date-Picker, React-Time-Picker, React-DateRange-Picker too :)
@wojtekmaj Thanks for your response!
Hi @wojtekmaj
We give the user visual feedback but the user has to correct the input on their own.
I tried to see if there is some class or something applied when the component is currently in a state where the user has chosen an invalid date, alas, I can't find such a thing.
I think, stopping the user from entering invalid values is quite complicated and can become inflexible: Depending on the values of other fields, some values are OK while others are not.
What would help often, I think, is
- if the component had a way to communicate that the current input is invalid according to the current settings.
- Some --invalid class applied to the whole component while the date entered is invalid.
Hi @wojtekmaj Is any updates for this issue?
Hi there, no, at the moment you cannot. We give the user visual feedback but the user has to correct the input on their own.
Looking at the behavior of native inputs, I think it should be done, though. I'll keep it on my list of potential enhancements.
I should also mention that the date has to be valid in order to be submitted via onChange, so you will never get an invalid date from the widget itself.
How can we give the user visual feedback by showing a message?
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.