Skip to main content
pixelgeekgirl
Participant
October 4, 2017
Answered

Custom Format Script Help: X or $

  • October 4, 2017
  • 1 reply
  • 2029 views

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

This topic has been closed for replies.
Correct answer Karl Heinz Kremer

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

1 reply

Karl Heinz  Kremer
Community Expert
Karl Heinz KremerCommunity ExpertCorrect answer
Community Expert
October 4, 2017

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

pixelgeekgirl
Participant
October 4, 2017

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!