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

296
Views
How to allow only Decimal values up to 2 decimal places in an input field in React JS

I have an Input field to which I want user to be able to enter only number/decimal values up to 2 decimal places. User should not be able to enter any alphabet. Can someone please help me with this

My React Component:

import React from 'react'
import { useState } from "react";

function LoanCalc() {
    const [amount, setAmount] = useState();

     const handleChange = (event) => {
         
     }

  return (
    <div className="Container">
      <div className="LoanAmount">
        <label>Loan Amount:</label>
        <span>$
          <input type="text" min="4000" max="100000" value={amount} onChange={handleChange}/>
        </span>
      </div>
    </div>
  );
 }
export default LoanCalc
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

check this codesandbox example

https://codesandbox.io/s/xo2x1qnw0w

additional to not restricting any invalid input this will round off if there is more decimal point

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!