Copy link to clipboard
Copied
How do I use the below script on more than 1 field as current it gives an error on other fields
if (event.value != "") {
event.value = util.printf("%0.2f",event.value)+"%";
}
Copy link to clipboard
Copied
Where does you use this script?
Copy link to clipboard
Copied
Adobe Accrobat DC standard
Copy link to clipboard
Copied
Does you use the code as calculation script?
Copy link to clipboard
Copied
By design, util.printf("%0.2f",x) will write 1.#R where x is not a number.
Copy link to clipboard
Copied
Please simplify your response.
How do I my code to avoid this from happening
Copy link to clipboard
Copied
Do not format data that is not a number. Check your input.
Don't ask me to write your script, please.
Copy link to clipboard
Copied
I changed the format to number, now I get the warning "The value entered does not match the format of the Field {Field name}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Does you divide by zero?
Copy link to clipboard
Copied
No, it is a code line to output a decimal and percentage sign.
Copy link to clipboard
Copied
You must check your input, I have said. What are your inputs and where are they from?
Copy link to clipboard
Copied
Try this, remove the format script so you can see what the "value" is that is causeing trouble. Then you can add code to test for that value.
Copy link to clipboard
Copied
I removed the string "%" and there is no error but once the string is removed there is no need for the script as the number format category displays the decimal. The script was created to have both the decimal and % sign out put. Another way would be using the percentage category and write a script to divide the value by 100.
Copy link to clipboard
Copied
So the idea is to find out what value is causing the problem with util.printf. Did you find out this infomation?
Copy link to clipboard
Copied
Do you have any calculations that are using division?
Copy link to clipboard
Copied
I updated my program to show decimal and % sign on my calculation
Copy link to clipboard
Copied
Is it working now?
You know, that after line #2 that "event.value" will never be 0.
Copy link to clipboard
Copied
Yes it is working. Sometimes the form is printed without filling the fields so we have to remove the 0