Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

258
Views
Proper way to "pre-validate" html input according to specific locale(formik included)

I need to pre-validate my inputs according to locale and defined "format type". For example: In some cases, it will be possible to enter only int values, in other cases it may be float, but with specific decimal places and so on.

What did I have for now:

  1. type = 'text', custom checks, formik problems. Input type='text' allows me to perform any checks I want in "onKeyPress" and other events. But the problem is - formik redrawing the input after each change and in case of entering Decimal separator, it will be erased(just because after the formik's setFieldValue 999. (or even 999.0) becomes 999). As I see it now, I can add a lot of ugly code inside custom Formik, but I feel like there is better way..

  2. type='number', locale problems. It allows browser to do most of the work using type='number': This works much better, I still can use events that I want, but the problem is even using my locale(en-US), it does not allow me to enter "." as a decimal separator, but allows me to use "," only.

There is also pattern attribute, but it can not be used with "number" inputs, so we have same problems like in the first case.

As for the showing - dynamically switching to "text" and showing formattted text with "Intl.NumberFormat" works pretty good.

I really feel like "reinventing the wheel", but there should be already invented one...

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!