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

239
Views
Input type number with comma React

I have a question about input type number in React. I need to display dot separator if user enter number with comma. Like this

11,2

Should convert to

11.2

How I can convert this number?I try

value.replace(/,/g, '.')

But this isn't working.I still see comma in my input.

PS: This how I handle input

<input
type="number"
placeholder='Input'
name="inputValue"
step="0.01"
inputMode="decimal"
id='inputValue'
min="0"
value={inputValue}
onChange={handleChange}
/>

And this is my handleChange function

const handleChange = e => {
let { name, value } = e.target;
value = value.replace(/,/g, '.');
setData(prevState => ({ ...prevState, [name]: value}));
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try this code:

const Number = "11,1";

console.log(Number.replace(/\,/, "."));


//Now your handleChange function will look like this:

const handleChange = e => {
  let { name, value } = e.target;
  value = value.replace(/\,/, ".");
  setData(prevState => ({ ...prevState, [name]: value}));
}

about 4 years ago · Juan Pablo Isaza Report
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!