Copy link to clipboard
Copied
Hopefully, someone can help me. I created a form in Acrobat. I set up one of the lines to enter as a percentage. The issue is when I enter (for example 50 thinking it would be 50% it shows as 5,000%.) I realize i could enter .50 and have it show up correctly. I am not familiar with Javascripting, but I believe a script can be written so what ever is entered will show up correctly. If I enter a 5 then it would show 5% etc. Does anyone know how to write this?
I would greatly appreciate your help!!
Sincerely,
Steve
Do not use the built in Format, select Custom on the Format tab and enter this script into the custom formatting box.
if(!/^\s*$/.test(event.value) && !isNaN(event.value)) event.value += "%";
This takes care of adding the % symbol, Now enter this code into the Keystroke script to prevent the user from entering non-numbers.
AFNumber_Keystroke(2, 0, 0, 0, "", true);
After this the display will revert to showing you entered a number format, but is will work the way you want
Copy link to clipboard
Copied
That's how Percent fields work. Their value ranges from 0 (0%) to 1 (100%). If you want it to work differently you would need to write your own keystroke, validation and format scripts.
Copy link to clipboard
Copied
Do not use the built in Format, select Custom on the Format tab and enter this script into the custom formatting box.
if(!/^\s*$/.test(event.value) && !isNaN(event.value)) event.value += "%";
This takes care of adding the % symbol, Now enter this code into the Keystroke script to prevent the user from entering non-numbers.
AFNumber_Keystroke(2, 0, 0, 0, "", true);
After this the display will revert to showing you entered a number format, but is will work the way you want
Copy link to clipboard
Copied
Excellent!! Thank you so much.