Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Javascript question for character counts and expanding text box

Avatar

Level 2

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

 

The file has been worked on in LiveCycle ES4 and AEM_forms designer ver. 6.4

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?

1 Accepted Solution

Avatar

Correct answer by
Employee

your main problem here is that you placed FormCalc in a JavaScript script and the fieldnames used are also not 100% logical

Here is a sample I made from your description - check if that is what you want to do. You can open the PDF in the Designer.

https://documentcloud.adobe.com/link/review?uri=urn:aaid:scds:US:005dc7d9-2c91-44b4-9ea7-50bb82d9772...

View solution in original post

2 Replies

Avatar

Correct answer by
Employee

your main problem here is that you placed FormCalc in a JavaScript script and the fieldnames used are also not 100% logical

Here is a sample I made from your description - check if that is what you want to do. You can open the PDF in the Designer.

https://documentcloud.adobe.com/link/review?uri=urn:aaid:scds:US:005dc7d9-2c91-44b4-9ea7-50bb82d9772...

Avatar

Level 2
I think I got it to work! Lots of comparison between the code on the original file, my working one, and your example. It's being tested by the PTB right now. Thank you!