8 Replies Latest reply on Aug 21, 2011 2:08 PM by try67

    Add a character to end of text field

    b.whitham Level 1

      I'm looking for a script that will add a character to the end of all text fields in a document. Or one that adds it to a single text field that I could add to all my text fields.

       

      The reason is that our end client will be copying and pasting text from the PDF and entering it into another system and it needs to maintain the line breaks at the end of the line. We thought this would be the safest route as it eliminates the potential for human error if someone doesn't enter it manually.

       

      I was playing around with fieldFull commands but can't seem to get anything to work. I thought something like…

       

      if(event.fieldFull) { getField(myfieldname).value = ":\n" }

       

      but that's not working at all; mostly due to my lack of programming expertise, I'm sure. Any help would be awesome.

        • 1. Re: Add a character to end of text field
          try67 MVP & Adobe Community Professional

          Do you want to do it after the fields have been filled, or at the moment the

          user exits the field after having entered a value?

          1 person found this helpful
          • 2. Re: Add a character to end of text field
            b.whitham Level 1

            Thanks for the quick response. That's a great question that I don't really have an answer for from a requirements stand point.

             

            What we have is an end-user tool that only allows a certain amount of characters per line and only a certain amount of lines. So we're faking some of this by having a single text field represent a single line with a character counter set on it and a max character limit set as well. Then theres a script running that focuses you to the next field as you've filled out each one. We just want to make sure that at the very end there's a hard return added to every line (text field) so when our client copies and pastes this it holds the formatting. Make sense?

             

            I guess whatever would be easiest is my best response to you. Maybe when they exit the field would make sense?

            • 3. Re: Add a character to end of text field
              b.whitham Level 1

              Sorry, also, if it helps give you some context you can follow our other discussion regarding this here…  http://forums.adobe.com/thread/892300?tstart=0


              • 4. Re: Add a character to end of text field
                try67 MVP & Adobe Community Professional

                I think the best option is to do it just before the file is closed. That way

                it's not interfering with the user's input.

                However, it might be problematic if the field is already full. I'm not sure

                you will be able to add an extra character to a full field.

                • 5. Re: Add a character to end of text field
                  George_Johnson MVP & Adobe Community Professional

                  Can you clarify (in words, not code) exactly which character(s) you want to add? It looks like you may be trying to add a carriage return to the end of a text field value, but this is not possible for non-multiline text fields. Any carriage return (or newline) characters get converted to spaces for non-multiline fields. For multiline fields, newlines (\n) get converted to carriage returns (\r), which have the same effect.

                   

                  Did you set a character limit for the field?

                  • 6. Re: Add a character to end of text field
                    b.whitham Level 1

                    Yes we'll need a carriage return added to the end of the fields. If it has to be changed to a multiline field that's not a problem. We'd like to have a max character amount set to the field as well and had assumed the last one could count as the carriage return. So, if we wanted 20 characters on a line, we'd set the max to 21 in order to hold the return.

                     

                    Is this possible?

                     

                    Thanks for all the responses. I've been  learning a lot on here today.

                    • 7. Re: Add a character to end of text field
                      George_Johnson MVP & Adobe Community Professional

                      I think the easiest way to get what you want is to keep the single line fields for user entry and then set up a separate multiline field that takes the contents of the individual fields and concatentates the values, adding carriage returns along the way. You can do this with a custom Calculate script in the multiline field. The text could then be copied from the multiline field when it later needs to be pasted into the other system. You can set it up the field in an out of the way area with white text so it's not noticable, but the end user would know where to go to copy it from. If this sounds feasible and you need help with the code, post again.

                      • 8. Re: Add a character to end of text field
                        try67 MVP & Adobe Community Professional

                        Just checked, and if the field has a maximum limit of characters then you can't add more characters to it, unless you also change the charLimit property before.