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

fix: numeric key filter validation for dash and dot input #7558

Closed

Conversation

navedqb
Copy link
Contributor

@navedqb navedqb commented Jan 3, 2025

Fixes #7557

Copy link

vercel bot commented Jan 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Updated (UTC)
primereact ⬜️ Ignored (Inspect) Visit Preview Jan 3, 2025 11:59am
primereact-v9 ⬜️ Ignored (Inspect) Visit Preview Jan 3, 2025 11:59am

@melloware
Copy link
Member

@navedqb this is intentional. KeyFilter by default just filters SINGLE keystrokes to prevent input but not validating something is a valid number. All of the PrimeTek libraries operate this way.

Look at the Whole Word example: https://primereact.org/keyfilter/#regexword

If you want to use int and only allow the negative at the start of the word try

<InputText id="numkeys" keyfilter={/^-?\d+$/} validateOnly onInput={validateInput} />

That will allow only 1 minus sign and it must be the first character only.

I am sure you can ChatGPT to find a good numeric one also that only allows one "decimal".

But the component is working as designed.

@melloware melloware closed this Jan 3, 2025
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

Successfully merging this pull request may close these issues.

KeyFilter: Incorrect handling of dash and dot in numeric inputs
2 participants