Copy link to clipboard
Copied
I have a basic form that all entries are numbers, with some fields that calculate the totals. My fields were set as Numbers and the calculations don't work if PDF is viewed in a browser. Instead of showing the value, it shows %0,02f. If I change the field format to be None instead of a number, that seems to at least work..numbers show and calculate, but with None set as field format, there.s not input validation to take a dollar amount of 10 and make it show up as 10.00 (like it used to as a number). Ive tried using a custom validation script like below, but it's still not appending the zeros like I'd like.
Any assistance would be greatly appreciated.
if (event.value == "" || event.value == 0) {
event.value = "-";
}
else {
event.value = util.printf("%0.2f", Number(event.value));
}
Copy link to clipboard
Copied
Does it work correctly when you use it in desktop application?
It's possibly browser app you use doesn't support javascript.
Copy link to clipboard
Copied
Yes, it seems to work fine when using the Reader software...but not in a modern browser such as Chrome or MSEdge. I keep thinking there's an answer here somewhere, but it's just eluding me.
Copy link to clipboard
Copied
I have also checked the 'allow JavaScript' setting in both Chrome and the new Chromium Edge and both are set to allow JavaScript.
Copy link to clipboard
Copied
Browsers suck at JavaScript and do not support AcroForms formats.
Make sure users open your form with Acrobat Reader, as shown in this tutorial (Google translate is your friend):
Copy link to clipboard
Copied
Where are you running this script from?
I am using your code in one field as custom calculation script and using this line of code in another field also as custom calculation script:
event.value = util.printf("%0.2f", event.value);
I opened this file in the new MS Edge browser and I am not getting this issue. See my slide below:
If the total field is already using util.printf as a custom calulating script to format the field don't use the built-in cutom format feature. It is redundant.
In my slide above I didn't need to enable the Acrobat's built-in custom format Number options from the "Select format category" dropdown. You can leave it as "None" because util.printf is already performing the desired formatting for that calculating field.
But in either case, I also recreated the same settings that you have on my end and using your script as custom format script, validtion script, custom caulcation script and it opened fine in MS Edge in all instances.
I think that if this field depends on other fields custom calculations you need to check those fields as well.
In addition, you may need to either force a manual update of the web browser and or MS Windows. Worst-case scenario uninstall and reinstall the web browser and try again. This will rule out other unforseen problems directly related to the PDF viewing capabilities of Chrome-based engine web browsers.