• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Changing number format using custom format.

New Here ,
May 03, 2021 May 03, 2021

Copy link to clipboard

Copied

Hello,

 

I have a global percentage and several rows with prices. I'd like to have a column next to them with the prices with the percentage applied to them, which is easy to do, but you end up with lots of 0.00 values if a certain row doesn't have any prices.

 

To solve it I'm using the following format script I found here:

event.value = (event.value != 0)?util.printf("€ " + "%,0.2f",event.value):"";

 

The problem is that it formats using a dot (100.00) for decimals, and I'd like a comma (100,00) but have no idea how to accomplish that.

 

If you have any tips I'd greatly appreciate it.

TOPICS
JavaScript , PDF forms

Views

2.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 03, 2021 May 03, 2021

Change 0 to 2:

event.value = (event.value != 0)?util.printf("€ " + "%,2.2f",event.value):"";

0 — Comma separated, period decimal point
1 — No separator, period decimal point
2 — Period separated, comma decimal point
3 — No separator, comma decimal point

Votes

Translate

Translate
Community Expert ,
May 03, 2021 May 03, 2021

Copy link to clipboard

Copied

Change 0 to 2:

event.value = (event.value != 0)?util.printf("€ " + "%,2.2f",event.value):"";

0 — Comma separated, period decimal point
1 — No separator, period decimal point
2 — Period separated, comma decimal point
3 — No separator, comma decimal point

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 04, 2021 May 04, 2021

Copy link to clipboard

Copied

Thank you Nesa, worked perfectly!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 27, 2023 Feb 27, 2023

Copy link to clipboard

Copied

LATEST

HI,
I used your formula to edit fields in a pdf file, but I have a small problem. I used the function you wrote:

event.value = (event.value != 0)?util.printf("€ " + "%,2.2f",event.value):"";

I would like, however, that if the number is an entire, the comma and the decimals were not applied. Eg:

5,12
5
12,25

and so on.

It's possible to do it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines