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 tab once a field is complete

Avatar

Level 1

HFB_911_Fill in form_Page_1.jpg

I'm making a fillable PDF order form for brick pavers. Is it possible to set up the form so that it will automatically tab you to the next open field once you enter in your letter? Right now, I've set the maximum character limit to one, so that people don't accidentally type more than one letter in a box- but It would be really annoying to have to tab inbetween each letter you type in.

I've uploaded a portion of the form, since I don't know how else to explain it.

5 Replies

Avatar

Level 4

I needed this for a form myself once and was given this and it works great.

Change Event in TextField1:
if (xfa.event.newText.length == 1)
{
xfa.host.setFocus("TextField2");
}

You would have to set this as the Change Event for each text field, telling it which text field to go to next.

So, for example, the Change Event for TextField2 would be:

if (xfa.event.newText.length == 1)
{
xfa.host.setFocus("TextField3");
}

Might be a little tedious for the large number of fields you have, but it should do the trick for you.

Jo

Avatar

Level 1

I might be showing my ineptitude with this program, but I don't understand! How do I set event fields?

I literally opened the program for the first time today. Sorry!

Avatar

Level 4

1) Click the first text field (I'm assuming your fields are called "TextField1", "TextField2", etc...).

2) In the script editor at the top, change the Language to Javascript, and change Show to the "change" event.

(If you can't see the script editor, click Window > Script Editor, and drag it open as much as necessary)

3) Paste in the following script:

if (xfa.event.newText.length == 1)
{
xfa.host.setFocus("TextField2");
}

Repeat these steps for each field, except change the name of the "setFocus" for each. So, for example, TextField2 will be:

if (xfa.event.newText.length == 1)
{
xfa.host.setFocus("TextField3");
}

...because you want to "set focus" on TextField3 after TextField2 has 1 character entered into it.

Hope this helps.

Jo

Avatar

Level 10

So you made that grid with individual text fields?

It would be easier to use a text field with "Comb of" set to the amount of characters you want per line. The Comb setting is on the Field Palette.

Make a text field the width you need it and then set the number of characters you want in the Comb. Each line will then be a field and you only need to tab when you're done with a line.