Copy link to clipboard
Copied
I've created several fillable PDFs for online use and I have set the number fields with 2 decimals but it automatically puts zeroes after the decimal. Is there a way to have it put the decimal before the last 2 numbers the user typed?
So instead of:
- user types: 123456
- returns 123456.00
We want this:
- user types: 123456
- returns 1234.56
Is this possible? Thank you.
Copy link to clipboard
Copied
To do that you would need to divide the value by 100. You can use this code as the field's custom Validation script:
if (event.value) event.value/=100;
Note that this changes the actual value entered by the user, not just how it is displayed!
Copy link to clipboard
Copied
Yes, but it requires a custom keystroke script, it could also be done with a custom validation.
What you are asking for is not formatting. Formatting is about managing how a value is presented to the user. You are asking to change the entered value. This type of script will not work if the PDF is opened in a browser or mobile app that is not the Adobe Mobile Reader. If this is a problem, then you might want to rethink the process.
Copy link to clipboard
Copied
Thanks very much, Thom -
Your comment about it not working if the form is opened in a browser or mobile app is especially helpful as well. We were trying to help our users avoid having to enter decimals, thereby (hopefully) reducing the chance of keystroke errors. We'll just have to change our process a bit.
Thanks again -
- Lorian
Copy link to clipboard
Copied
To do that you would need to divide the value by 100. You can use this code as the field's custom Validation script:
if (event.value) event.value/=100;
Note that this changes the actual value entered by the user, not just how it is displayed!
Copy link to clipboard
Copied
Thanks very much!! I tried it and it works beautifully!
Now we just need to decide if that's the way we want to go, since both options have their pros and cons. If we're instructing the user that the system will automagically insert a decimal before the last 2 numbers they type, then it will allow them to just use the number keys, which might be simpler. Many are not super computer-literate.
Thanks again to you both!
- Lorian
Copy link to clipboard
Copied
One more question on this - if the last digit is a zero, the output is being calculated correctly but it's not displaying the zero at the end, so it looks like it's just giving 1 decimal place.
For example, if the user enters 123456, it's correctly reflecting 1234.56.
BUT if they enter 543210, it's reflecting 5432.1
Is there a way to set it so it will include the zero at the end, so it would be 5432.10?
I realize they're the numericaly and financially the same, but they're visually jarring and just look sloppy, and also will likely cause doubt for our users as to whether it's working correctly.
Thank you!
Copy link to clipboard
Copied
I tried it and the last zero was kept in tact. Did you set the field's Format to Number with 2 decimals?
Copy link to clipboard
Copied
No - I had set it to Custom so I could use the script, but now I see I can (and apparently should) do that on the Validation tab.
Thanks!!
One (hopefully) final thing - I'm not able to multi-select the fields to which I want to apply this formatting, so I have to set them each individually, which just takes a long time. Any trick to that or is it a glitch in the app? I can set other attributes on multiple fields at once...
Thanks again!
Copy link to clipboard
Copied
No, there's no trick. You can't apply a Format setting (or any other action, for that matter) en masse via Acrobat's UI. It can only be done using a script, like this (paid-for) tool I've developed:
https://www.try67.com/tool/acrobat-mass-edit-fields-actions
Copy link to clipboard
Copied
OK - thanks very much.