5 Replies Latest reply on Jul 6, 2011 10:29 AM by Herk4

    Copy Field 1 to Field 2 in different font

    Herk4

      In my pdf I have Text Field 1 in font X.  I would like to automatically copy the text from Field 1 to Text Field 2 but have it in a different font.  I know how to change the fonts but I need help with the script so it copies the text.  Thank you.

        • 1. Re: Copy Field 1 to Field 2 in different font
          George_Johnson MVP & Adobe Community Professional

          If the fields have the same name, they will automatically get the same value. If you don't want to do that, you can copy the value from field 1 to field 2 with the following custom Validate script for field 1:

           

          getField("text2").value = event.value;

          1 person found this helpful
          • 2. Re: Copy Field 1 to Field 2 in different font
            try67 MVP & Adobe Community Professional

            Just use the Simplified Calculation option and enter Field1 into the box

            (the field's name can't have spaces in it, though).

            • 3. Re: Copy Field 1 to Field 2 in different font
              Herk4 Level 1

              Thank you very much.  The script is exactly what I need.

               

              Can I get more complicated?

               

              Field 1 is a regular font.

              Field 2 is a barcode.

               

              If I code Field 1 TESTLOT123, Field 2 is readable with a scanner.

              Is there a way to script so Field 2 would add the start and stop * in case the user forgets to add them?

               

              Field 1 would read TESTLOT123.

              Field 2 would read TESTLOT123 and automatically add a *before the T and a * after the 3.

              • 4. Re: Copy Field 1 to Field 2 in different font
                George_Johnson MVP & Adobe Community Professional

                To add an asterisk at the beginning and end of the string, the code could be:

                 

                getField("text2").value = "*" + event.value + "*";
                


                Although you may want to do this:

                 

                (function () {
                
                    var f = getField("text2");
                
                    f.value = event.value ? "*" + event.value + "*" : "";
                
                })();
                

                 

                which blanks the second field if the first field is blank. If you think the user may enter a leading or trailing asterisk, you might want to check for that before adding any.

                • 5. Re: Copy Field 1 to Field 2 in different font
                  Herk4 Level 1

                  This worked great. Now I have another question and this will be the last! I appreciate your time and help.

                   

                  If I type XG22012DC in Field 1 I would like Field 3 to calculate a date based on this information.

                  X can be a variable that can be:

                       X = 2009, Y = 2010 Z = 2011

                  G can be a variable that can be:

                       A=January

                       B=February

                       C=March

                       D=April

                       E=May

                       F=June

                       G=July

                       H=August

                       I=September

                       J=October

                       K=November

                       L=December

                  22 is a variable for the day 1-31

                   

                  The rest of the numbers do not mean anything.  The end date for this would be 07/22/2009.