Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Javascript question for character counts and expanding text box


Level 2

I have an old form that was created by someone else in 2015 in LiveCycle. I am working on it in Designer but have very little experience with it; I'm mostly learning by doing.

I have two text fields where I need to have a character count, one for characters used and another for characters remaining. Even though I'm working from the original file where this worked, in my new version I keep getting errors, even though I haven't changed anything.

The first field is called shorttitle which has a 40 character max, and the count shows the characters left. The next one is abstract, and that needs to be an expandable text box and the character count shows the characters used. Neither of those work.


I'm not sure what the JavaScript should be or where I put it... in the Script Editor, I presume. I've tried all kinds of things, from using the original code to using code examples found by googling, but I'm having no luck. Any help would be greatly appreciated; I've been working with this darn thing on and off for almost a year.


For the shorttitle I show the following in the Script Editor:


 form1.titlesponsorsf.titlesponsordatasf.projecttitles.shorttitle::change - (JavaScript, client)

charactermaxsf.shorttitle = 40 - Len(xfa.event.newText)


The field hierarchy is:
projecttitle (text field)
shorttitle (text field)
charactermax (text)
shorttitlecharleft (numeric field-value Calculated-Read Only; Calculation Script)




The other field is an expanding text box called abstracttext This has a 200 character minimum.

The field hierarchy for this is:

abstracttextsf (subform)
abstracttext (text field with multiple lines and page breaks allowed, plus Expand to fit on Height checked)
abstractcharacterminsf (subform)
abstractcharactermin (text)
abstracttext (numeric field-value Calculated-Read Only; Calculation Script)


The code for the abstracttext field is:


 form1.abstractsf.abstracttextsf.abstracttext::change - (JavaScript, client)
abstractcharacterminsf.abstracttext = 0 + Len(xfa.event.newText)



Please, is there anyone who can help?

0 Replies