Copy link to clipboard
Copied
I'm trying to create a field in a PDF that might contain decimal numbers and calculates this field with another field. As an example, when I write 2.3 in the fillable field, the equation works, but when I write 2,3, the result is NaN. I want to replace the comma I wrote in the field with a dot, or if there is some other workable solution to make this calculation work, I exept all solutions. I have tried with JavaScript (value.replace (/, /, '.')) But I can not make it to work or I'm placing it to a wrong place or something. Please notice that I'm not good at coding.
Can anyone help with this?
If you want to write , and field to show , but to calculate as decimal try select this option:
Copy link to clipboard
Copied
Why not simply use the built-in Format option that has a comma as the decimal separator? That will allow you to enter the value directly with the comma, and will handle it correctly in later calculations.
Copy link to clipboard
Copied
Tried that. If I write 2,3 it gives me back 23.00?
Copy link to clipboard
Copied
What option did you select under the Format tab?
Copy link to clipboard
Copied
Also, make sure to remove the code you applied earlier, which removes the comma from the text...
Copy link to clipboard
Copied
Thanks for your tip. Actually right now all the Format tab options calculate right??? Nesa Nuranis code workes also. I don't know what happened, but thank you for your tips.
Copy link to clipboard
Copied
That's exactly what I suggested you do, but OK...
Copy link to clipboard
Copied
Yep, it just didn't work the first time I tried it. Maybe closing and re-opening the file did something and this suggestion started to work.
Copy link to clipboard
Copied
So you want to write 2,3 but field to show 2.3?
try this as custom format script:
event.value = event.value.replace(",",".");
Copy link to clipboard
Copied
If you want to write , and field to show , but to calculate as decimal try select this option:
Copy link to clipboard
Copied
Is there a way to edit all fields at once? Because if I choose more than one field the window "format" doesnt show up, only when I choose a single field.
Copy link to clipboard
Copied
Not manually. It can be done using a script, though, like this (paid-for) one I've developed:
https://www.try67.com/tool/acrobat-apply-format-to-multiple-text-fields
Copy link to clipboard
Copied
This worked perfectly. Thank you very, very much!!