Copy link to clipboard
Copied
I am trying to figure out how to go about writing a custom javascript format so that the form field allows for either a number with two decimal spaces or an "X" - these fields will later be calculated into a total. If i leave the field with no formatting then I do not get he comma formatting if the user enters a number over 999, and the user can input any letters rather than just X - and I need it to be limited to numbers or an X only.
If anyone has a source online that they have used that will help me write my own please let me know, otherwise any input would be much appreciated.
Thanks,
Kelley
You need more than a formatting script: A formatting script will format a correct value in a certain way. However, when the user enters data, you don't know yet if the data is actually in either the two digit numeric format, or just the letter "X", so you need to verify first that that is the case. This can be done either by a custom keystroke script, or a custom validation script - or a combination of the two. Once you know that the data is correct, you can then use your custom formatting scrip
...Copy link to clipboard
Copied
You need more than a formatting script: A formatting script will format a correct value in a certain way. However, when the user enters data, you don't know yet if the data is actually in either the two digit numeric format, or just the letter "X", so you need to verify first that that is the case. This can be done either by a custom keystroke script, or a custom validation script - or a combination of the two. Once you know that the data is correct, you can then use your custom formatting script to correctly format the data (if there is still a need to do that).
Take a look here for some information about how to create custom validation scripts: Adobe Acrobat JavaScript: Validating Fields with Custom Validation Scripts
Copy link to clipboard
Copied
Thank you so much for replying so fast! I really appreciate it. What you are saying makes complete sense... I will start with validation.
Thanks!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now