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.

How to automatically navigate to the next field without pressing the TAB key?

Avatar

Former Community Member

The form has phone number fields, they are not actual special formats for phone numbers, they did not do that to begin with.    So the phone number of form will end up being entered into two different fields one numeric 3 digit and (the next in tab order) is a text field with validation text{999-9999} .   What user is asking for now is this sort of flow:

    1. User of from tabs into the 3 digit number field
    2. Types one digit,
    3. Then another
    4. And another
    5. After they type the third digit the form should automatically move to the text field
    6. After it fills up with an acceptable 999-9999 string then that field should move the focus onto the next field in tab order. 

I can get the ‘full’ event to move focus to the next field but that happens only when the forth number is keyed, but that number is not passed to the text field.   Could not find a way of ‘carrying’ that number forward and placing the cursor to its right. 

So I was looking at the ‘Change’ event, to set up an IF like this:

if (this.length = 3 ) then xfa.host.setfocus("TX17") ;

from what I can tell this does not get a length until TAB or ENTER is pressed.   Can anyone help?

4 Replies

Avatar

Level 2

Hi,

Instead of writing Script in Change event, write it in full event.

Beofre that make the Field, limit length - Max Chars 3. and in full event write

xfa.host.setfocus(TX17);

Avatar

Former Community Member

The set focus to move to the field will work, and I set that TXT17.rawValue to the last character of xfa.event.fullText to populate the TXT17 field.  But when the focus is set to it that text is selected.  So when user presses the next number it will replace what is selected.  I can’t find a way setting focus to the field and placing the cursor at end of the field. 

radzmar example works fine if pasting text but does the same thing if text is typed. 

Avatar

Level 10

You can fix this behavior with a script.

It will continue the entered text at the end of the fields current value, even the whole text is highlighted.

Put it into the change:Event.