Skip to content
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

Prevent non-numeric input #614

Open
viveleroi opened this issue Dec 15, 2023 · 3 comments
Open

Prevent non-numeric input #614

viveleroi opened this issue Dec 15, 2023 · 3 comments
Assignees

Comments

@viveleroi
Copy link

Is there a way to prevent non-numeric input entirely, rather than stripping it out?

For example I can type "foo" into the input, and it's displayed as a value, but then stripped when I blur the field. I need to prevent those characters from being typed in at all. I tried pattern/inputMode just in case but neither do what I need.

Is this possible?

@yoyo837
Copy link
Member

yoyo837 commented Dec 16, 2023

Is it possible to do this in controlled mode?

@viveleroi
Copy link
Author

Are you asking me? I'm not sure what you mean. I guess I need to intercept the onChange or something and prevent anything but numbers/decimals?

@viveleroi
Copy link
Author

Just in case, the onChange isn't called until a parseable number is present in the field. So if I typed "hhh" the onChange isn't fired until I type an actual number. So I have no power to remove characters as the user types. This feature would need to be handled in the library and should be opt-in.

In BlueprintJS the prop is called allowNumericCharactersOnly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants