Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Where do you create word count for text fields?

Avatar

Former Community Member

I am really new at creating forms in LiveCycle Designer and would like to know where to enter word count script for text boxes? I have found references to JavaScript strings but don't even know where to start typing them.

Is there an on-line users guide?  Is there a place to send the pdf and have someone look at it??

Also I get an error when I go to Preview Design or when I actually open the PDF I created.  When you hit OK it appears to work correctly. My computer tech thinks I have something locked but can't seem to find it.

here is the error message:

Script failed (language is formcalc; context is

xfa[0].form[0].form1[0].#subform[0].Header[0].Comments[0])

script=lock fields

Error: access or 'lock' is unknown

I spent an entire day trying different things but very unfairly with Javascript and where to enter it.

3 Replies

Avatar

Level 6

Create a new text field named wordcount

Add:

var wordCnt = new Array();var str = this.rawValue;wordCnt = str.split(" ");xfa.resolveNode("wordcount").rawValue = "There are " + wordCnt.length + " words.";

to the text field you want to count the words in.  The tally will display in the wordcount field

Avatar

Level 6

remove that script.  Add a new textfield named wordcount

Add this to the text field you want to count:

var wordCnt = new Array();var str = this.rawValue;wordCnt = str.split(" ");xfa.resolveNode("wordcount").rawValue = "There are " + wordCnt.length + " words.";

Avatar

Level 1

var wordCnt = new Array();

var str = this.rawValue;

wordCnt = str.split(" ");

xfa.resolveNode("wordcount").rawValue = "There are " + wordCnt.length + " words.";

I added the script above to the layout:ready event of text field #1 and created a second text field named wordcount. The number of words appears in the wordcount field as soon as I leave the first text field. But I would like it to appear immediately while I'm typing. How can that be done?

Thanks!