Formatting Numeric Only with Variable Decimal Places

Acrobat Pro 9, Windows XP
I'm creating a form that has a number of text box form fields that are to be numeric only per the form requestor. However, for any given field of this type the number of decimal places that can be entered can vary from 0-3 and the requestor does NOT want any unnecessary decimals to appear in the final output (e.g., a "1.2" entry should not appear as "1.200"). The standard number formatting properties always show all the decimal places so I know it's not that route. No calculations will be performed with any of these entries -- the form requestor merely is entering data and then printing it out so that it's legible for the end-user.
I know that the following line of JavaScript in the Custom Keystroke property limits the entry to numeric only, but how should I tweak the syntax to allow a decimal entry:
     event.rc = (!event.change || /^\d$/.test(event.change))
I probably also need a script to format for decimal places, but I don't know where to look in the JavaScript for Acrobat API Reference or in the MDN JavaScript Reference.
Thanks in advance for any assistance.

Good question. To keep it simple (because there are about 300 form fields in this document), if they choose to add extra decimal zeros, then who am I to argue with their entry. So in your example for a given form field, if they enter "1.200" then I expect that they want "1.200" to display.
OK, but earlier you said:
"However, for any given field of this type the number of decimal places that can be entered can vary from 0-3 and the requestor does NOT want any unnecessary decimals to appear in the final output (e.g., a "1.2" entry should not appear as "1.200")."
This seems inconsistent. Can you clarify? The point is the code and where it's placed depends on this. It could be implemented either as a custom Validate or Format script, in addition to a Keystroke script.

Similar Messages

  • !!!! How to maintain the value with 2 decimal places !!!

    hi
    i have a double var and i need to maintain it with 2 decimal places only..
    thanks..

    What do you mean with you need to "maintain it" with 2 decimal places?
    Do you want to display the number with 2 decimal places? If so, have a look at the API documentation of java.text.DecimalFormat.
    double d = 3.14159265358979;
    NumberFormat f = new DecimalFormat("0.00");
    System.out.println(f.format(d));

  • Problems of setting values% with 2 decimal places in any graphics. What sho

    Guys, I have the xcelsius 2008 and can not make it work chart with values % and 2 decimal places. Already set up everything that I know the spreadsheet and graphics.
    Someone knows what can I do?
    Thanks Anderson - Sao Paulo - Brazil.

    Hi Anderson,
    To get values in % and upto two decimal, follow the below steps:
    Go to Chart properties-> Appearences Tab-> Text tab.
    Select the "Vertical Axis Labels" and go to the Number format present below in the window.
    Change the format to "Percentage" and set decimal places to "2".
    This should work.
    Please revert incase you have any queries.
    Thanks,
    Amit Mathur.

  • Uploading Number with Two Decimal Places

    I am trying to import data from my excel file to table in the database using SQL Developer.
    It is working fine except that in my excel file I have data with two decimal places, but during import it shows only one decimal place. Is there any way I can import data with two decimal places?

    This works well with SQL Dev 1.5.X.
    Guess it would have been a bug in prior versions.

  • Convert amount with four decimal places to amount with two decimal places

    Hi,
    for specific reasons we have set the prices to four decimal places. However, in an invoice the staff needs to see all prices with two decimal places. Therefore I have created new user-defined fields which should show the rounded values However, I have not yet found the right formatted search that outputs the value with two decimal places including currency symbol.
    The statement 
    SELECT $[$38.20.NUMBER]
    outputs the value with two decimal places which is fine, but it does not contain the currency.
    The statement
    SELECT $[$38.20.0]
    outputs both value and currency, but the value still has four decimal places as the original price.
    And the statement
    SELECT CAST($[$38.20.NUMBER] AS VARCHAR(20)) + $[$38.20.CURRENCY]
    outputs a value with even six decimal places.
    Did anyone already have the same problem???
    Or does anyone have any idea???
    Thanks and regards
    Corinna

    Hi again,
    the value should be displayed in a user-defined field of the screen.
    The result of the query
    SELECT $[$38.20.NUMBER]
    has already two decimal places, so that I do not need a round here. But the currency is missing.
    When I add the round function to the query
    SELECT $[$38.20.0]
    it does unfortunatly result in an error.
    Any ideas????
    Thanks so much in advance!

  • Help!printing float values with two decimal places

    hi there java pips! im a newbie to this technology so forgive me for this really stupid question....i would like to perform mathematical operations on two float values....the problem is i want to print them in a standard format and that is i want them to be displayed with two decimal places (e.g 190.00, 12,72, 1,000.01) how can i do this?

    Try java.text.DecimalFormat
    NumberFormat nf = new DecimalFormat("0.00");
    System.out.println(nf.format(x));

  • Displaying all numbers with 2 decimal places

    Hi All,
    We have a requirement in our code where we want that all numbers must be diplayed with 2 decimal places.
    Eg: If a number is 21.234 then it should be displayed as 21.23
    If a number is 21.289 then it should be displayed as 21.28
    If a number is 21 then it should be displayed as 21.00
    Can anyone please help me how to do it in a SQL query.
    Regards,
    Shruti

    Hi, Shruti,
    This shows a couple of things you can do:
    COLUMN     trnc     FORMAT     999999.99
    WITH     got_x     AS
         SELECT     empno / 1000     AS x
         FROM     scott.emp
    SELECT     x
    ,     TO_CHAR (x,            '999999.99')     AS tc
    ,     TO_CHAR (TRUNC (x, 2), '999999.99')     AS trnc_tc
    ,     TRUNC (x, 2)                              AS trnc
    FROM     got_x
    ;Output:
    `        X TC         TRNC_TC          TRNC
         7.369       7.37       7.36       7.36
         7.499       7.50       7.49       7.49
         7.521       7.52       7.52       7.52
         7.566       7.57       7.56       7.56
         7.654       7.65       7.65       7.65
         7.698       7.70       7.69       7.69
         7.782       7.78       7.78       7.78
         7.788       7.79       7.78       7.78
         7.839       7.84       7.83       7.83
         7.844       7.84       7.84       7.84
         7.876       7.88       7.87       7.87
           7.9       7.90       7.90       7.90
         7.902       7.90       7.90       7.90
         7.934       7.93       7.93       7.93Column x is the number, as SQL*Plus displays it by default. Note there are as many digits after the decimal point as are needed.
    Column tc shows how TO_CHAR can format the number, with exactly 2 digits after the decimal point. This automatically rounds the number to the nearest multiple of .01, so on the first row (for example) 7.369 gets displayed as 7.37.
    user11272043 wrote:
    ... If a number is 21.289 then it should be displayed as 21.28You (apparantly) always want the number rounded toward 0, so column tc isn't quite what you want.
    Column trnc_tc is exacly what you requested, with the numbr rounded toward 0 (when any rouning is necessry) and 2 digits after the decimal point.
    Column tc is also exactly what you requested, but it uses SQL*Plus formatting rather than SQL. Also, column trnc is a NUMBER, while column trnc_tc is a VARCHAR2, because TO_CHAR, as its name hints, returns a VARCHAR2.
    The SQL*Plus command
    SET   NUMFORMAT  999999.99changes the default format for all number columns. If you use this, you can override it for individual columns by using TO_CHAR (since it returns a VARCHAR2, the NUMFORMAT doesn't apply),or a COLUMN command. Also, if you use SET NUMFORMAT 999999.99, you'll still have to explicitly TRUNC every number, or else 21.289 will come out as 21.29, not 21.28.

  • Display amount in ALV Grid with different Decimal Places based on Currency

    HI Experts,
    Working with ALV Report i have one Amount field NETWR which is having Length 15 and Decimal Places 2.
    we have two different types of currency's AED and KWD and AED having 2 decimal Places and KWD having 3 decimal places.
    im using FM: REUSE_ALV_GRID_DISPLAY for Display. value storing in Table was like this
    AED---22.56
    KWD---225.65
    i need to display values like AED : 22.56

    HI Experts,
    Working with ALV Report i have one Amount field NETWR which is having Length 15 and Decimal Places 2. we have two different types of currency's AED and KWD and AED having 2 decimal Places and KWD having 3 decimal places.
    im using FM: REUSE_ALV_GRID_DISPLAY for Display. value storing in Table was like this
    AED---22.56
    KWD---225.65 (converting this value to 22.565 using BAPI_CURRENCY_GETDECIMALS according to currency in my Report)
    i need to display values like AED : 22.56
                                             KWD---22.565 but here field is NETWR with 2 decimal.
    Need to Display amount in ALV Grid with different Decimal Places based on Currency
    Regards,
    Dileep Kumar Reddy

  • Displaying results with a decimal place of two. Forcing decimal place.

    Hi there,
    Im writing a simple calculation device.
    You input one digit and press one of two buttons to multiply it by a certain number and then the result is displayed. The result is displyed hiding the result of the button you didn't press and visa versa.
    I am having a problem displaying the result with a constant two decimal place.
    I am using strings and thus don't know how to do this.
    Here is my code:
    import flash.events.MouseEvent;
    //restrict the input textfield to only numbers
    txtinput.restrict = "0-9";
    //restrict the input textfield to only two characters
    txtinput.maxChars = 6;
    // event listeners
    btnW.addEventListener(MouseEvent.CLICK, WHandler);
    btnC.addEventListener(MouseEvent.CLICK, CHandler);
    btnW.addEventListener(MouseEvent.CLICK, hideC);
    btnC.addEventListener(MouseEvent.CLICK, hideW);
    //functions
    function WHandler (e:MouseEvent):void
              //white calculation
              var answerW:Number = Number(txtinput.text) * Number(0.90);
              txtWResult.text = answerW.toString();
    function CHandler (e:MouseEvent):void
              //colour calculation
              var answerC:Number = Number(txtinput.text) * Number(0.99);
              txtCResult.text = answerC.toString();
    function hideC (e:MouseEvent):void
              //Hide colour result
              txtCResult.visible = false;
              txtWResult.visible = true;
    function hideW (e:MouseEvent):void
              //Hide white result
              txtWResult.visible = false;
              txtCResult.visible = true;
    After having a look online I have found these two resources:
    http://helpx.adobe.com/flash/kb/rounding-specific-decimal-places-flash.html
    and
    http://stackoverflow.com/questions/11469321/decimals-to-one-decimal-place-in-as3
    But I am confused when combining these techniques with strings.
    Any help would be greatly appreciated,
    Thanks in advance
    Mr B

    Use the toFixed() method of the Number class instead of the toString() method.  The result of it is a String with the number of decimal places you specify.
              var answerW:Number = Number(txtinput.text) * Number(0.90);
              txtWResult.text = answerW.toFixed(2);
              var answerC:Number = Number(txtinput.text) * Number(0.99);
              txtCResult.text = answerC.toFixed(2);

  • Need to restrict numeric entry to two decimal places

    Hello,
    I have a cfform with a cfinput of type=text. I need to restrict what can be entered into the cfinput so that it allows only two decimal places. I have tried the mask, but it won't work because "99999.99" will not allow 12.34 and "99.99" will not allow 12345.67.
    I have read about validate and pattern but I've never used them. I don't know JavaScript, but I can copy and paste pretty well.
    Any help you can provide is greatly appreciated.
    Thank you,
    Jim

    *795589,*
    What particular percent complete are you having trouble with?
    *(Found in the P6 knowledgebase) This issue is an existing Enhancement Request. It will be considered for a future release*
    Other than that, maybe try creating a global change to manually calculate your percents.
    hope this helps,
    +*** Can the number of decimal places for Percent Complete be changed? [ID 895884.1] Modified 30-OCT-2009+

  • Work duration with 2 decimal places

    All, i need to maintain a task with 25 min, using unit of measure H. Is there any way of setting up the work duration for tasks with more than  1 decimal place? Or the only way is to have different unit of measure?
    Thanks,
    Ana

    Hello AA,
    Use unit of measurement as 'MIN' - Minutes for duration. Rest SAP will take care.
    Vaibhav Mishra

  • A double with 2 decimal places

    I need to output a double that has 2 decimal places. The default is just one and I don't know the command to make it two. For example,i want an output of 37.5 to be displayed as 37.50. If you know the command, please tell me. Thanks!

    Looks like you are trying to deal with money.
    Firstly if you are dealing with money store everything as the lowest form of currency in your given area. eg as pence or cents and place it in a int or long. That way you dont get any rounding erros when you multiply up the value.
    To put two decimal places on a number is easy just use a DecimalFormat from java.text
    Like this
    double myNumber = 3.1;
    DecimalFormat decF = new DecimalFormat( "######0.00" );
    String myFormattedNumber = decF.format( myNumber );
    System.out.print( "My number is " + myFormattedNumber ); The #######0.00 in the DecimalFormat constructor call is a pattern that is used to format the number. The # indicate an optional number the 0 indicates a required number and if one is not provided a 0 will be included.

  • Formatting a Double to 2 decimal places without first converting to String

    Hi,
    Does anyone have any clear idea on how to format a Double directly without first converting it
    to a String.I have just read through DecimalFormat/NumberFormat but I think there might be an easier way.I am also aware of printf(%f) and format(%f),but unfortunately am using Java 1.4 at the moment which does not seem to support them(will upgrade soon).The code I have is as follows:
    public void displayAnalysis ()
           System.out.println ("========================================================================");
           System.out.println ("========================================================================");
           System.out.println ("\nANALYSIS RESULTS FOR FILE " + inputFile + " \n");
           System.out.println ("========================================================================");
           System.out.println ("========================================================================");
           System.out.println ("\nString length: "+ inputText.length());
           System.out.println ("Ratio of printing to non-printing characters: "+ pRatio);
           System.out.println ("Ratio of vowels to consonants: "+ vRatio);
           System.out.println ("");
           System.out.println ("Frequency of vowels as a percentage of number of printing characters;");
           System.out.println ("Percentage of a's ="+ (NumberFormat.format(new DecimalFormat(((double)frequency[0]*100)/printable)))));
           System.out.println ("Percentage of e's ="+ ((double)frequency[1]*100)/printable + "%");
           System.out.println ("Percentage of i's ="+ ((double)frequency[2]*100)/printable + "%");
           System.out.println ("Percentage of o's ="+ ((double)frequency[3]*100)/printable + "%");
           System.out.println ("Percentage of u's ="+ ((double)frequency[4]*100)/printable + "%");
           System.out.println ("Number of whitespace characters were " + whitespace);
           System.out.println ("");
           System.out.println ("========================================================================");
           System.out.println ("========================================================================");
           System.out.println ("");
           System.out.println ("");
       }I would like to display the frequencies to 2 decimal places.As a last resort I will have to alter the code to use DecimalFormat,but I'm hoping someone has a simpler solution.

    Oops,please ignore the line for the first frequency (a's),I was just playing around with trying to use NumberFormat!

  • Formula Variable decimal Places

    Dear All,
    Is there any way i can remove decimal places from Formula Variable / Type Number / Ready for Input ?
    Plz help ASAP.
    Regards,
    SS

    Is that you don't want the user to enter any decimal values for this variable???
    Then best way is to create a Formula Key Figure of type Customer Exit. then you can writ the code in I_STEP =3 whoich will do the validation and throw an error message in case of deciaml values.

  • Member calculated with extra decimal places

    Hello experts,
    I import a file in which all the figures have a maximum of 2 decimal places but the problem is that the first-level parent of the accounts have 9 or more decimal places. ¿Does someone know how could I fix the problem?
    Thank you very much,
    Alvaro

    Hi,
    To set that you need to go to BPC web admin> Application parameter> There you will find SIGNED_DATA_FORMAT, If not add it and update it.
    Then in second column provide the number you want before decimal and after decimal say 26 digit before decimal and 2 after decimal then it will be 26,2 and update it.
    After this modify the application to rebuild indexes and process the application to have the new format.
    Regards
    Raman

Maybe you are looking for

  • Problem for Sound Format.

    Hi, I have developed a Game and it uses the .wav file works very well in Emulator. I sent that game to Game distributor, This is the reply i got. We found no problem to implement into Device and it works properly except with NO sound Game use "wav" f

  • How to create object from Table?

    Hi all, Is there any command to create an object type from a table? I i want to that command to create object type from emp table insted of typing the following command: CREATE TYPE emp_t AS OBJECT (empno NUMBER(6), ename VARCHAR2(25), job VARCHAR2(1

  • Is there a way to store mp4 video files on iCloud that can be read by either QuickTime or ITunes?

    Is there a way to store mp4 videos in iCloud so that they can be accessed by my IPad using Itunes or QuickTime.  I'd like to travel with only my IPad. Many Thanks

  • Unity Backup Best Practices

    We are looking at our Disaster Recovery when it comes to our Unity Voicemail servers and I am looking for some Best Practices when it comes to backing up Unity. Does anyone have any whitepapers/suggestions? Thanks.

  • Bulk deploy application to Collection

    0 Can some one please tell me what I have wrong here? $apps = Get-CMApplication -Name 'Adobe CS6*' foreach ($app in $apps){ echo $App.LocalizedDisplayName Set-CMApplicationDeployment -ApplicationName $app.LocalizedDisplayName -CollectionName 'ATL-USE