Highlighted

## Simple Field Value Question

New Here ,
Oct 08, 2020

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));
}

TOPICS
PDF forms

Views

68

Likes

Report

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

## Simple Field Value Question

New Here ,
Oct 08, 2020

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));
}

TOPICS
PDF forms

Views

69

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 08, 2020 0
5 Replies 5
Contributor ,
Oct 08, 2020

Copied

Does it work correctly when you use it in desktop application?

It's possibly browser app you use doesn't support javascript.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 08, 2020 0
New Here ,
Oct 09, 2020

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.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 09, 2020 0
New Here ,
Oct 09, 2020

Copied

I have also checked the 'allow JavaScript' setting in both Chrome and the new Chromium Edge and both are set to allow JavaScript.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 09, 2020 0
Oct 09, 2020

Copied

Browsers suck at JavaScript and do not support AcroForms formats.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 09, 2020 0
LATEST
Oct 09, 2020

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.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 09, 2020 0
Resources