3 Replies Latest reply on Mar 1, 2008 7:43 PM by (Jansen_Neo)

    specifying numbers only in form fields

      I am running Acrobat 7.0.9 on MacOS 10.4.11. I wish to specify that a form field be filled with numerals only within a form, and in any order, eg a field for telephone number or serial number. If I go to "Text Field Properties" and apply the "number" category to text field, this is fine for monetary amounts but if you have a number sequence beginning with zero, Acrobat won't allow it because it sees it as an amount and sees the zero as being unnecessary. So if I wish to key in the sequence 012345, Acrobat sees it as 12345. I guess I need to use the "Custom" option to define JavaScript, but have no knowledge of JavaScript. Can anybody suggest a simple JavaScript that will allow me to key in any sequence of numerals only, or can anybody suggest another solution? Thanks.
        • 1. Re: specifying numbers only in form fields
          gkaiseril MVP & Adobe Community Professional
          Custom format script:

          // 6 digit number no separator no decimal
          event.value = util.printf("%,106d", event.value)

          Custom keystroke:

          // define a regular expression for any length number
          var reNumber = /^\d*$/;
          // run only if event not committed
          if(event.willCommit == false){
          // set event return code to result of re test
          event.rc = reNumber.test(event.change);
          }

          Documentation available from Adobe:

          Acrobat SDK; http://www.adobe.com/devnet/acrobat/
          Acrobat JavaScript Documentation: http://www.adobe.com/devnet/acrobat/javascript.html
          Acrobat FDF Toolkit: http://www.adobe.com/devnet/acrobat/fdftoolkit.html
          PDF Reference: http://www.adobe.com/devnet/pdf/pdf_reference.html

          The above sites include additional links to other PDF information.

          Books:
          Adobe Acrobat Bible series by Ted Padova
          Adobe Acrobat Tips and Tricks by Donna L. Baker
          Extending Acrobat Forms with JavaScirpt by John Deubert
          Creating Dynamic Forms with Adobe LiveCycle Designer by J. P. Terry

          Adobe Sponsored forums:
          Acrobat User-to-User forums: http://www.adobeforums.com/cgi-bin/webx/.3bbeda8b/
          Acrobat User Community: http://www.acrobatusers.com/

          Other Forums:
          Planet PDF Forums: http://forum.planetpdf.com/wb/default.asp

          Other PDF Sites:
          Planet PDF: http://www.planetpdf.com/
          Windjack Solutions: http://www.windjack.com/
          Ted's Homepage: http://www.west.net/~ted/index.html
          Abracadabra PDF: http://www.abracadabrapdf.net/index.php?lng=en
          NitroPDF: http://www.nitropdf.com/index.asp
          D. P. Story (Acrotex): http://www.acrotex.net.
          PDF Zone: http://www.pdfzone.com/

          JavaScirpt:
          JavaScript Central: http://devedge-temp.mozilla.org/central/javascript/index_en.html
          • 2. Re: specifying numbers only in form fields
            Level 1
            Geo

            Thanks very much - the custom keystroke option is perfect!!
            • 3. Re: specifying numbers only in form fields
              Hi

              This doesn't work for me. The zero is still being taken off. Any ideas?

              Thanks