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

percentage formatting, input box <=> form state mismatch #826

Open
naseemkullah opened this issue Feb 13, 2024 · 0 comments
Open

percentage formatting, input box <=> form state mismatch #826

naseemkullah opened this issue Feb 13, 2024 · 0 comments

Comments

@naseemkullah
Copy link

similar to #825

with something like

format={(value: string) => {
  const stripped = value.replace(/\D/g, '');
  return stripped ? `${stripped}%` : '';
}}

and an isAllowed rule allowing just 1 to 100 values, typing e.g. "555" results in 55% displayed visually, but 555 in the form state value.

Using with react-hook-form FWIW.

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

1 participant