3 Replies Latest reply: Jul 27, 2012 6:33 PM by chad Snelson RSS

    Form Field Label

    chad Snelson Community Member

      I have the same question as this thread <http://forums.adobe.com/thread/756410> plus a little bit extra.

       

      So the answer (which has worked out wonderfully) was submitted by George:

       

      // Custom format script for text field

      if (!event.value) {

          event.value = event.target.userName;

          event.target.display = display.noPrint;

      } else {

          event.target.display = display.visible;

      }

       

      But as George eluded in his first post in the thread was:

      The problem with this approach is it precludes easily using any of the built-in formats that you may want to use (Number, ZIP code, etc.). You still can, but it requires more scripting.

       

      So how can I get the combination of the Form Field Lable being displayed and also the auto formatting for Phone numbers, Zip Codes etc.?

       

      Any help is greatly appreciated.

       

      I'm running Acrobat X Pro on Windows if that matters.

       

      Message was edited by: chad Snelson 

      Updated question: 

      So I was thinking about it some more and remembered seeing this line of code:

      event.value = util.printx("99-9999999", event.value); From <http://forum.planetpdf.com/wb/default.asp?action=9&fid=34&read=43365>.

       

      And then the Arbitrary Mask formatting option

      <http://help.adobe.com/en_US/acrobat/standard/using/WS58a04a822e3e50102bd615109794195ff-7de 4.w.html>

      and it appears that the tax id line of code uses those same guide lines.   So is there away to use George's section of code and combine it with the tax id line of code and just use the Arbitrary Mask formatting rules so if one text field was for a zip use George's section and just change the tax id line so instead of all the nines it would just have 99999 ? If this makes any sense or is possible if someone could please reply with an example I'd greatly appreciate it!

       

      So I was playing around with combining both soultions and just added the Tax ID formatting to George's part and came up with this:

       

      // Custom format script for text field

      if (!event.value) {

          event.value = event.target.userName;

          event.target.display = display.noPrint;

      } else {

          event.target.display = display.visible;

          event.value = util.printx("99-9999999", event.value)

      }

       

      So that works great if you put in a total of nine numeric characters but if you input letters then it still lets you it just doesn't show them verses the arbitrary mask formatting option where it doesn't even let you put in letters and requires the right about of numeric characters.

       

      So my new question/problem is how to only allow numeric characters to be entered and require the right ammount of characters with the above code?

        • 1. Re: Form Field Label
          chad Snelson Community Member

          HORRAY!!!! Actually I got the code to work!!!!!!!!!

          I have no idea how that works (again I know nothing about coding).

           

          All I had to do was change it so it was:

           

          // Custom format script for text field

          if (!event.value) {

              event.value = event.target.userName;

              event.target.display = display.noPrint;

              event.target.textColor = color.red;

          } else {

              event.target.display = display.visible;

              event.target.textColor = color.black;

              event.value = util.printx("99-9999999", event.value);

          if (event.value.length !=10) {

          event.value = "";

          app.alert("Tax ID # does not have the required 9 numbers!", 0, 0)

          }

          }

          • 2. Re: Form Field Label
            GKaiseril CommunityMVP

            The Tax ID also can refer to the Social Security Number that is used by individual taxpayers.

            • 3. Re: Form Field Label
              chad Snelson Community Member

              I'm confused by what you mean.