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

223
Views
How do i hide the currency symbol when there is no input?

So i am making a create product page. The items were product name, product price, product description. There are gonna be times where user doesnt want to input any price on their product just yet. In that case i dont want it to show currency with the value 0 on the page. Is there any way to hide the currency? thank you

const [price, setPrice] = useState();

  const formatter = new Intl.NumberFormat("id-ID", {
    style: "currency",
    currency: "IDR",
  });

<p className="card-text">{formatter.format(item.price)}</p>
almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can add a condition to check the empty value of item.price on your JSX like below

<p className="card-text">{Boolean(item.price) && formatter.format(item.price)}</p>

If you want to reuse that formatter for other values, I'd suggest you introduce a function

const formatCurrency = (priceValue) => {
   if(!priceValue) {
     return '';
   }

   return new Intl.NumberFormat("id-ID", {
    style: "currency",
    currency: "IDR",
  });
}

<p className="card-text">{formatCurrency(item.price)}</p>
almost 4 years ago · Santiago Trujillo 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!