Expand my Community achievements bar.

Setting Text Fields

Avatar

Level 1
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?
4 Replies

Avatar

Former Community Member
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?

Avatar

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

Avatar

Former Community Member
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.

Avatar

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