3 Replies Latest reply on Aug 21, 2009 3:40 PM by Shallowmyre

    Is it possible to count words in a field

    Shallowmyre

      Is it possible to count words in a field, and have the results of that count show up in another field in LiveCycle? Such as the following regular html Javascript Code: If so, what is the correct syntax for the two different boxes??? Thanks! Daria

        • 1. Re: Is it possible to count words in a field
          Jasmin Charbonneau Level 4

          I think the only way would be to have a function that split the value of the field based on spaces.

           

          Jasmin

          • 2. Re: Is it possible to count words in a field
            Kevin Cavallo Level 4

            Check out the attached example.  It uses regular expressions, so some caveats:

             

            1. My regex skills stink, so it may not count words as perfectly as you like.  It's pretty tolerant of special characters but a string like "this & that" will count as 3 words, since the & is counted as a word.  You can tweak the regular expression to adjust to your needs.

             

            2. Since this uses javascript regular expressions, it will work fine in Reader and Acrobat but I don't think it will work for forms rendered on the Livecycle server (such as in Output).  For some reason regex support is missing in the Livecycle server javascript engine; or if it is there it doesn't work on my server.

             

            The script is in the exit: event of the data entry text box.  You can type in (or paste) text into that text box and when you tab out of the box the word count will update.  You can move the script into a different event on your form depending on when you need the words counted.

             

            Let me know how this works out for you.

            • 3. Re: Is it possible to count words in a field
              Shallowmyre Level 1

              Keven,

               

              Thanks, this works great in LiveCycle, at least so far. I really appreciate it.

               

              Daria