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

Is there any way to prevent invalid values from being typed on hour/min/sec inputs?

Open yjw9012 opened this issue 5 years ago • 9 comments

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

yjw9012 avatar Jul 11 '18 15:07 yjw9012

@wojtekmaj Any help would be appreciated.

yjw9012 avatar Jul 16 '18 19:07 yjw9012

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.

wojtekmaj avatar Jul 19 '18 07:07 wojtekmaj

I see. Thank you!

yjw9012 avatar Jul 19 '18 18:07 yjw9012

@wojtekmaj Does your answer apply to react-time-picker as well, correct?

yjw9012 avatar Jul 19 '18 18:07 yjw9012

Yes, it does. To React-Date-Picker, React-Time-Picker, React-DateRange-Picker too :)

wojtekmaj avatar Jul 23 '18 12:07 wojtekmaj

@wojtekmaj Thanks for your response!

yjw9012 avatar Jul 23 '18 15:07 yjw9012

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.

flq avatar Nov 30 '18 11:11 flq

Hi @wojtekmaj Is any updates for this issue?

vmkarpenko avatar Mar 05 '20 09:03 vmkarpenko

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?

kurasaiteja avatar Dec 02 '20 07:12 kurasaiteja

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 Feb 13 '23 01:02 github-actions[bot]

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

github-actions[bot] avatar Feb 27 '23 01:02 github-actions[bot]