Copy link to clipboard
Copied
Hello,
Can anyone offer any suggestions on how to write a Java or Validation script so the result is always a negative number? The PDF I'm working on has a field (which is named l6) that is a field that one can enter a number. I'd like the number to always be a negative, so if one enters 3,000 then when they hit enter I'd like the number to be -3,000. If they enter -3,000 then I'd like the number to be -3,000 for the field (l6) that they are entering the number for. I feel like a validation script is the way to go with this but honestly i have no idea. Thank you in advance for any input
Copy link to clipboard
Copied
Use this script.
if(event.value > 0) event.value = -event.value;
Copy link to clipboard
Copied
Use this script.
if(event.value > 0) event.value = -event.value;
Copy link to clipboard
Copied
I used if(event.value > 0) event.value = -event.value; to make the row for the "Less: (Advance)" always a negative number.
The row below it, is the totals, so in Adobe, i created the calculation formula to be a the sum of everything on that column (which would really subtract the "Less: (Advance)" ).
When I do "preview" in Adobe, all the validations and calculations work.
When I save the file as a PDF into my computer, and when I try to fill out that file from the hard drive, the calculation adds the "Less: (Advance)" row instead of it treating it as a negative number. How can I get it to work?
Copy link to clipboard
Copied
Do you use Acrobat to fill form?
Did you use a calculation script to calculate the total?
Copy link to clipboard
Copied
Also, that code doesn't make the value "always" negative. It negates the current value, which if it is already negative, makes it positive. And the script is intended to be used as a Validation Script. If you used it as a calculation script, then you must ensure the calculation order is setup correctly.