2 Replies Latest reply on Mar 7, 2008 3:28 PM by (Jansen_Neo)

    The zero in front

    Level 1
      Hi all

      Acrbat Professional 8

      Can someone please show me how to use javascript to leave the '0' in front of numbers? I've used the following to copy a number box but some how it left the zero in front out:-

      var name = this.getField("Name").value;

      event.value = name;

      Please help.

        • 1. Re: The zero in front
          gkaiseril MVP & Adobe Community Professional
          Field format "none" or you code the custom Keystroke and format scripts.

          Custom calculation script:

          var nDecSep = 0;
          var cFlags ="0";
          var nWidth = 11;
          var nPrecision = ".2";
          var cConvCahr = "f";
          var cFormat = "%," + nDecSep + cFlags + nWidth + nPrecision + cConvCahr;
          var name = this.getField("Name").value;
          event.value = event.value = util.printf(cFormat, name);

          For more information about the "util.printf()" method see the JavaScript API reference

          Acrobat JavaScript Documentation: http://www.adobe.com/devnet/acrobat/javascript.html

          Or create the custom Keystroke and format scripts as outlined:


          and modify the custom format to:

          event.value = util.printf("%,0011.2f", event.value)

          or as needed for the desired display.

          and use your custom calculation script as is.
          • 2. Re: The zero in front
            Level 1
            Hi Geo the Scriptmaster

            Thanks for the reply, but that did not work. All I wanted is for the 2nd text box to show exactly what the I input in the 1st text box i.e.
            0123 showing 0123.

            I've seen your previous post showing how to do exactly this, but it did not work as well.

            Please help