8 Replies Latest reply on Nov 6, 2008 12:31 AM by (Zahari)

    Field format properties

      Can I change text field's format properties with javascript ?
        • 1. Re: Field format properties
          gkaiseril MVP & Adobe Community Professional
          No you can not.
          • 2. Re: Field format properties
            George_Johnson MVP & Adobe Community Professional
            What properties would you like to change? If you provide a bit more context, we may be able to suggest an approach.

            George
            • 3. Re: Field format properties
              Level 1
              Hi,
              Thanks for the answers. I have simple adobe form with text fields in it on Properties -> Format, I want to change format category to Number and on Properties -> Validate, I want to change Field value is in range.
              Can I do this with javascript ?
              • 4. Re: Field format properties
                George_Johnson MVP & Adobe Community Professional
                Yes, you can use JavaScript to set the various event actions using the setAction field method. To set the number format type, you have to set up a Format script and a Keystroke script:


                // Format script for
                // number, two decimal places
                AFNumber_Format(2, 0, 0, 0, "", false);

                // Keystroke script
                // two decimal places
                AFNumber_Keystroke(2, 0, 0, 0, " ", false);


                And for a Range validation script:


                // Validation script
                // In this example, 42 is the minimum
                // and 999 is the maximum
                AFRange_Validate(true, 42, true, 999);


                So the code that sets these field actions might look like:


                var f = getField("your_text_field");

                f.setAction("Format", "AFNumber_Format\(2, 0, 0, 0, \"\", false\);");
                f.setAction("Keystroke", "AFNumber_Keystroke\(2, 0, 0, 0, \"\", false\);");
                f.setAction("Validate", "AFRange_Validate\(true, 42, true, 999\);");


                You'll have to study these various built-in functions to see how they behave, but this should get you started.

                George
                • 5. Re: Field format properties
                  Level 1
                  Hi,
                  Thanks for the answer everything works fine. Can you tell me where I can read more about :
                  AFRange_Validate
                  AFNumber_Format
                  AFNumber_Keystroke
                  and other properties like this, I don't find anything in JS API Reference.
                  • 6. Re: Field format properties
                    George_Johnson MVP & Adobe Community Professional
                    They are not documented anywhere that I know of, but you can get the code listing by entering the function name in the JavaScript console and executing the line:

                    AFRange_Validate (Ctrl + Enter)

                    George
                    • 7. Re: Field format properties
                      gkaiseril MVP & Adobe Community Professional
                      See, http://www.planetpdf.com/forumarchive/125041.asp, for more information about the AFNumber_Format() function. There was a small amount of documentation about these Acrobat builtin form functions in the version 5 JS Reference.

                      AFRange_Validate

                      Purpose:
                      JavaScript function to populate the field value range of fields with the number or percentage format.

                      Syntax:
                      AFRange_Validate(bGreaterThan, nGreaterThan, bLessThan, nLessThan)

                      Parameters:
                      bGreaterThan - logical value to indicate the use of the greater than comparison

                      nGreaterThan - numeric value to be used in the greater than comparison

                      bLessThan - logical value to indicate the use of the less than comparison

                      nLessThan - numeric value to be used in the less than comparison
                      • 8. Re: Field format properties
                        Level 1
                        Thanks for the answers you really help me a lot. I'll see what google can tell me about this secret functions.