-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to reject invalid times? #27
Comments
You can use the
This way you'll always get a correct value in your |
It's not allow input 17:00 |
Closing as @mikhail-denisenko response should allow you to configure this to support this behavior in some capacity. Alternatively, with #30, you should be able to manage this with your |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am using this for a time input with a mask of
11:11
. However, not all digits are ok for a time. Hours over 23 and minutes over 59 should be prohibited.I have my component which wraps react-maskedinput but that only has access to onChange to read the entered value. How can I reject
3_:__
right away (as soon as the user types 3 for the hour, I know it's wrong) or27:__
or14:8_
.I cannot stop this from onKeyDown (as I believe it should be done) as it's not available. I was thinking you should allow
props.onKeyDown
, call it first in your_onKeyDown()
and skip the rest of the function ifprops.onKeyDown()
returns false (or ife.isDefaultPrevented()
maybe). This way you allow the users to reject keypresses based on their own logic.I can send a PR if this sounds ok but I wanted to hear from you first - maybe there's an easier way to do the above that I missed?
The text was updated successfully, but these errors were encountered: