Highlighted

Setting Text Fields

Avatar

Avatar

pgcarter

Avatar

pgcarter

pgcarter

14-05-2008

Hello - is there a way in Designer to set the text field to automatically go to the next box? I have a form with individual boxes for letters of both first name and last name and you have to hit tab to type each letter. I want the cursor to automatically move to the next box. Can that be done in Designer?

Replies

Highlighted

Avatar

14-05-2008

To clarify your question. Do you want only one letter for each TextField, and then once you enter one letter per field, you want it to automatically go to the next field? This can be done. What version of Designer are you using?
Highlighted

Avatar

Avatar

pgcarter

Avatar

pgcarter

pgcarter

15-05-2008

Yes, that is exactly what I want to do [it is an existing form] I am using 7.0
Highlighted

Avatar

15-05-2008

This is what I did in Version 7.1.2, but it should work in 7.0.



I created four TextFields: TextField1, TextField2, TextField3, TextField4. If it is a TextField, under the Field tab, I also limited the max. characters to 1. If it is a numeric field, you don't have that option, but using the script below will limit the maxLength to 1 character.



On the Change event, using JavaScript, I added the following script:



var maxLength = 1;

var currentLength = xfa.event.newText.length;



// Change focus to next field if maxium length reached.

if( currentLength == maxLength )

{

xfa.host.setFocus("TextField2");

}



What this script should do, is once it reaches the maxLength (being 1), it sets the focus to the next field. Add this script to the second field, changing the object name to "TextField3", etc.
Highlighted

Avatar

Avatar

pgcarter

Avatar

pgcarter

pgcarter

16-05-2008

It worked! Your instructions were perfect [I've never used script editor before]. Thank you so much.