Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Script to add a decimal to a number
  FAQ FAQ  Forum Search   Register Register  Login Login

Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

Script to add a decimal to a number

 Post Reply Post Reply
Author
Z-Slayer View Drop Down
New Member
New Member
Avatar

Joined: 29 May 2013
Location: Missouri
Points: 2
Post Options Post Options   Quote Z-Slayer Quote  Post ReplyReply Direct Link To This Post Topic: Script to add a decimal to a number
    Posted: 29 May 2013 at 6:27pm
I found this forum today on my search to find how to format my PDF.  I have a fill-able form PDF and one of the fields is asking for a number.  I have had issues with this field in the past and I would like to correct it.  

It is a 6-digit number and some users will enter it as XXXXXX and some will enter it as XX.XXXX.  If I format the field through Adobe with 4 decimal places, if the user enters XXXXXX it will appear as XXXXXX.0000.

What script will I need to take whatever number they input (whether it be either format) and have it appear as XX.XXXX?
Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4111
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 29 May 2013 at 6:44pm

I would use the validation tab and enforce the entry to require a value between 0 and 99.9999.



Edited by gkaiseril - 29 May 2013 at 6:45pm
Back to Top
Z-Slayer View Drop Down
New Member
New Member
Avatar

Joined: 29 May 2013
Location: Missouri
Points: 2
Post Options Post Options   Quote Z-Slayer Quote  Post ReplyReply Direct Link To This Post Posted: 29 May 2013 at 7:03pm
The problem with the validation tab is it won't let you input a number over 100.  These are classification numbers so I will need to see all of the numbers that they enter.  For example, a classification number might be 30.9735.  One user might enter that as 309735 and another might enter it as 30.9735.

All numbers will be 6-digits.  I just want to have them all be in the same format.
Back to Top
mmazal View Drop Down
New Member
New Member
Avatar

Joined: 20 Jan 2012
Location: Kitchener, ON
Points: 10
Post Options Post Options   Quote mmazal Quote  Post ReplyReply Direct Link To This Post Posted: 17 Jun 2013 at 3:18pm
Perhaps you could use a custom keystroke script that only allows numbers to be typed into the field.
Then use a custom format script that displays a decimal after digit number 2.
Back to Top
try67 View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Points: 634
Post Options Post Options   Quote try67 Quote  Post ReplyReply Direct Link To This Post Posted: 20 Jun 2013 at 11:35am
You can use something like this as the custom Validation code (remove any Format settings you applied):

event.rc = true;
if (event.value) {
    if (/^\d{6}$/.test(event.value)) {
        event.value = event.value.substring(0,2) + "." + event.value.substring(2);
        event.rc = true;
    } else if (/^\d{2}\.\d{4}$/.test(event.value)) {
        event.rc = true;
    } else event.rc = false;
    if (!event.rc) {
        app.alert("You must enter a number in the following formats only: 99.9999 or 999999");
    }
}



- Acrobat Expert - Contact me personally at try6767@gmail.com
Check out my custom-made scripts website: http://try67.blogspot.com
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.031 seconds.