Copy link to clipboard
Copied
I have Number fields in an Adobe Acrobat form that need to be able to be entered as either a whole number or a decimal. Easy enough. I also need up to two decimal places shown, also easy. However, I can't figure out a way to hide the trailing zeros in a decimal in order to "clean up" the look of it. For example:
I type What appears I want
8.25 8.25 8.25
22.7 22.70 22.7
3 3.00 3
Does anyone know how to do this?
Thanks,
Custom format script
event.value = util.printf("%,02.2f",event.value).replace(/\.?0+$/,"");
Copy link to clipboard
Copied
Thanks. It worked. I also added the same script to text4 and a script for rounding the final result.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
this.getField("Text1").display = (event.value=="") ? display.hidden : display.visible;
If I place this script in the "Run Custom Validation Script" of the "Name field", then the "Text1" becomes invisible.
I have to click enter on the keyboard for it to work ( is that normal ? ).
But what if I want all the text fields ( exactly 9 ) in the row to disappear at the same time ?
Thanks
Copy link to clipboard
Copied
Is there also any kind of script that would make invisible all the fields of the same page ?
Thanks
Copy link to clipboard
Copied
Yes, However, this is a completely different topic than the forum thread. You should consider posting it to a new thread.
Just to provide some quick answers.
1) The validation script is run after the user commits the data to the field, but before the data is actually commited, which is of course what validation is all about, checking the data before it is fully committed to the field. The user signals that they want the data committed by pressing enter or exiting the field.
2) There are a few different ways to write a script that hides/shows several fields at the same time. You'll find a more infomation here:
https://www.pdfscripting.com/public/Hiding-and-Showing-Form-Fields.cfm
Copy link to clipboard
Copied
You must round the calculated values.
Copy link to clipboard
Copied
The "invisible decimals" are the actual value of the fields, so that's what you will get when you export the form data. If you don't want that to happen then you need to change the actual value, not just format it, or use a script to perform the rounding on the values when you export them.