Copy link to clipboard
Copied
In some forms, when the user types in, for example, the area code for their phone number, they are automatically tabbed to the cell for the 3 digit prefix and upon completing the prefix they are automatically tabbed to the final cell for the phone number. I know that the user can hit the tab key themselves, but is Acrobat capable of automatically doing this using form fields created in Acrobat in version 9 or 10 Pro?
It should be the actual name of the next field. The problem with that particular script is for a text field with a three character limit, you have to attempt to enter another character before it will set the focus to the next field.
Here's a function you can create in a document-level JavaScript that you can call in a text field's custom Keystroke JavaScript that should behave as you want:
// Document-level function
function tab_next(next_field_name) {
// Move to next field if Enter key is press
...Copy link to clipboard
Copied
Sure, see the first example here: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.609.html
Copy link to clipboard
Copied
George,
Thanks for your reply. This looks promising.
I set up 3 text fields. The first two have a limit of 3 characters and the third one a limit of 4 characters.
I copied the JavaScript and put it in the Action for each of the three fields:
if ( event.fieldFull || event.willCommit )
this.getField("NextTabField").setFocus();
I'm not sure if I'm supposed to change "NextTabField" to the actual name of the next field or leave it as is,
so I tried it both ways. In either case, it's not working for me. After typing 3 characters into the first field,
I have to manually hit Tab to go to the next field. The same for the other two fields.
Any ideas about what I'm doing wrong?
Copy link to clipboard
Copied
It should be the actual name of the next field. The problem with that particular script is for a text field with a three character limit, you have to attempt to enter another character before it will set the focus to the next field.
Here's a function you can create in a document-level JavaScript that you can call in a text field's custom Keystroke JavaScript that should behave as you want:
// Document-level function
function tab_next(next_field_name) {
// Move to next field if Enter key is pressed
// or the user has clicked outside of the field
// or if the number of character is the character limit
if (event.willCommit || AFMergeChange(event).length === event.target.charLimit) {
getField(next_field_name).setFocus();
}
}
Then call it like this as the Keystroke script of a text field:
// Autotab to the "text2" field
tab_next("text2");
This particular script will only work if you're set the character limit for the field from which it is called. There are a lot of autotab scripts that folks have created for use with Acrobat (some better than others) that address a particular circumstance, so you'll probably run across more with a search.
Copy link to clipboard
Copied
George,
Thank you for kindly answering my question. The form is working fine now.
Copy link to clipboard
Copied
George,
A couple of months ago you provided a script on Acrobat Users that has to do with tabbing. It's one that would be useful for me, but I've not been able to make it work. I hope you can help.
As I understand it, with this script, it's not necessary to enter a character limit in Options for a field. Once the maximum number of characters that the field can hold is reached, whatever that may be, the cursor should then move to the next text field.
http://acrobatusers.com/forum/forms-acrobat/acrobat-9-pro-autotab
The script is as follows:
function AutoTab(doc, event, cNext, nChar)
{
// Call the built-in routine to allow numbers only or other validation script
// AFNumber_Keystroke(0, 0, 0, 0, "", true);
/*
If we've filled in the field completely, jump to the next one.
if (event.rc && AFMergeChange(event).length == event.target.charLimit)
doc.getField(cNext).setFocus();
*/
// use the passed nChar parameter
if (event.rc && AFMergeChange(event).length == Number(nChar))
doc.getField(cNext).setFocus();
}
In the individual text fields, I'm using the Custom Keystroke script:
// Autotab to the "Text2" field
tab_next("Text2");
Copy link to clipboard
Copied
I didn't post that script, George Kaiser did. And it doesn't do what you said it does.
Copy link to clipboard
Copied
George,
I apologize for the confusion.
Copy link to clipboard
Copied
Not a problem.
As that first script I directed you to shows, there is an event.fieldFull property that is set automatically when the field can't accept any more characters due to it's size (or character limit). The problem is, it doesn't get set until after you attempt to exceed it, which is understandable since there might be enough space for a "." but not a "W". This is how the example 1 script in the documentation behaves. So you can do what you want if you can live with this behavior.
Copy link to clipboard
Copied
You post to AUC has 2 different user functions.
The first uses the field's maximum character length property. The second uses a passed parameter that specifies the maximum length. Please read all the text of the post and all the comments in the code.
I will also point out that the AUC scripts include a a call to another function that only allows the entry of numeric values.
The first script was written to simulate the action of comb fields, prior to Acrobat having such a field option. At the time when Acrobat was introduced, one might create a series of individual form fields for the entry of the SSN or other numeric data. This type of field is used on OCR forms. Then the user needed to tab to the next field as each number was entered. The comb field type allows for individual boxing of numbers but allows the access of the entered values as a single value. Other wise, one needed to adjust each individual field for the decimal position in the number and compute what the entered numbers is a single value.
Copy link to clipboard
Copied
I am still somewhat new to javascripting. Where does the document level Javascritpt go. I've done most of my learning on the form field by trial and error. This may help me tremendously.
KS