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

Flowing text from Textfield1 to textfield2

Avatar

Former Community Member

New to LiveCycle but have figured out dynamif forms and textfields that flow from page 1 to the next page if needed. What I need to do is have "textfield1" fill but not expand and then as the user types, the focus needs to chane to textfield2 automatically and start filling.

There are other fields betwen "textfield1" and "textfield2" that cannot move.

I'm totally new to javascripting and just cannot figure this out. Help would be greatly appreciated, including errecting statues of you in my office.

14 Replies

Avatar

Level 10

See if this helps..

https://acrobat.com/#d=1o1rXLswbe*O0UvnLCDSZA

I am checking the length of the First TextField value and if it exceeds certain number, I am setting the focus to Second TextField..

Code is in the change event of the First TextField.

Thanks

Srini

Avatar

Level 7

You can also place this script in the full event of textfield1:

xfa.host.setfocus(form1.subform1.textfield2);

where form1 would be replaced with your form name and subform1 would be replaced with the name of the page that textfield2 is on.  This works no matter the font size or textfield size, but of course textfield1 must be set to not expand.

Avatar

Former Community Member

Interesting question. Srini's approach works well for fields with monospaced input fonts such as Courier.

I've been experimenting with the scenario of not having to limit the amount of characters.

So far I've come up with the following (the two text fields are called f1 and f2):

//f1::full
f2.rawValue = xfa.event.fullText.replace(xfa.event.newText, "");
xfa.host.setFocus(f2);

//f2::change
if (!xfa.event.selStart)
xfa.event.change = xfa.event.prevText+xfa.event.change;

Ugly, I know, but it does the job for slow-typers.

Being able to alter xfa.event.target before Acrobat commits the event would be nice...

Avatar

Former Community Member

djaknow: I think you will lose a character in the transition.

Avatar

Former Community Member

This may work if I could easily calculate the total character length of the field. Any suggestions?

Avatar

Former Community Member

Well this looked easy, but once I tried it, it didn't work. Got some error messages and yellow yield signs on my textfield1. Textfield1 should be set to Limit to visible area right? what else should i check?

Avatar

Level 7

That's true, the user would have to realize the focus has changed and add the missing character. The only advantage is that it doesn't require monospaced font.

Avatar

Former Community Member

Well, that won't do because they probably won't notice.

Avatar

Level 7

No matter which method you use, either the user will have to pay attention or you'll have to find a way of figuring out whether or not a word cut off in the middle. Even with monospaced font and a fixed number of characters allowed it's still highly likely you're going to be in the middle of a word when the switch to the new field occurs.

Avatar

Former Community Member

Well, if they cannot do it without paying attention (um, my clientbase is not a group of great typers so they are likely to be looking at the keyboard), wouldn't it be easier to just make textfield1 limited and then have then reset the tab order to textfield2 opposed to using a script? It sure seems to me that there should be a way so that it is seemless to the user.

Avatar

Level 7

You could still use the script to make the change but then maybe also pop up a message box telling the user what happened? I don't know of a way to effect a switch to a new text field midstream without any user attention required.

Avatar

Former Community Member

Is this correct? My two fiels are Narrative12 (f1) and Narrative 13 (f2)

//Narrative12::full
Narrative13.rawValue = xfa.event.fullText.replace(xfa.event.newText, "");
xfa.host.setFocus(Narrative13);

//Narrative13::change
if (!xfa.event.selStart)
xfa.event.change = xfa.event.prevText+xfa.event.change;