These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Auto Tab issue

n4467r
Registered: Jun 7 2007
Posts: 9

I have been provided with the following code but find that it only tabs when numbers entered:

function AutoTab(doc, event, cNext)
{
// Call the built-in routine to allow numbers only.
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();

What I need is for the auto tab to function when any character is entered. I am not fimiliar with java but see that it is calling a numbers only routine when I need a character routine.

I also have this"AutoTab(this, event, "MemIDB4");" in the properties under format and custom keystroke script.

Thanks for the help!

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Since the script is checking the length of the entered data to the field's maximum character limit, "AFMergeChange(event).length == event.target.charLimit", you need to set the field's character limit under the "Options" tab.

George Kaiser

n4467r
Registered: Jun 7 2007
Posts: 9
I had the character limits set to "1" under the options tab as the fields are for things like first name, last name, address and such where you enter each cnaracter in a box (the form is also used for scan). I was thinking there is somethin in the "AFNumber_Keystroke" causing my problem??

Thanks...
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Have you considered setting up a comb field for this? If you've ruled that out, there are cleaner approaches to this than what you're attempting. Post again if you're interested.

George
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
n4467r wrote:
I had the character limits set to "1" under the options tab as the fields are for things like first name, last name, address and such where you enter each cnaracter in a box (the form is also used for scan). I was thinking there is somethin in the "AFNumber_Keystroke" causing my problem??Thanks...
This is designed for number because the "AFNNumber_Keystroke()" funciton only allows keystrokes.

You will need to modify this fucntion for alphabetic input, but you would not want to change the default funciton with something like:

The following modified 'Auto Tab" function can process both numeric and non-numeric values, when place

function goNextAlpha(oItem, oEvent, cName, bAlpha) {
/* Tab to next field when field character limit is reached.
Includes alpha fields
Includes error trapping and displays on JavaScript console
the error, field where error occurred and next field name.

parameters:
oItem - required - item where fields to process reside
oEvent - required - field being processed
cName - required - next field's name
bAlpha - optional - identifies an alpha field

Place call to this function in the fields custom format.
The user responsible for checking format of field.
Default number check is for the standard numeric values.
"0-9" for single character fields and includes sign values for multi character fields.

Call for numberic field:
goNextAlpha(this, event,"NextField");

Call for alphabetic field:
goNextAlpha(this, event "AlphaNextField", true);

*/
try{ // error catcher
if (bAlpha) { // parameter for alpha true
if (AFMergeChange(oEvent).length == oEvent.target.charLimit) oItem.getField(cName).setFocus();
} // end alpha
else { // process as a number
AFNumber_Keystroke(0, 0, 0, 0, "",true);
}
if (oEvent.rc && AFMergeChange(oEvent).length == oEvent.target.charLimit) oItem.getField(cName).setFocus();
} catch(eMsg) { // trap error display error message, field in and next field
app.beep(3); // beep
} finally { // always run
return; }

} //end goNext

The goNext function was first presented as a user function in version 4 by Ted Padova.

The above code could also be modified to force the alphabetic entry to upper case.

George Kaiser

n4467r
Registered: Jun 7 2007
Posts: 9
Turns out that when I eliminate the AFNumber_Keystroke routine the process works as desired and characters including numbers can be input. THe code looks like this:

function AutoTab(doc, event, cNext)
{// 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();}


George, I would be interested to see how this could be done in a less complex way. The form is actually an information form to capture name, address, Id number and other related items. All fields are 1 character in length with the exception of the email address and a comments section.

Thanks for all the help!
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
The main reason to look for an alternative is the clunky user interface with using a separate field for each character and using setFocus to automatically move to the next field. This is especially apparent when trying to edit such a "field".

If you have not considered setting up a text field as a comb field, you should look into it. To create a comb field, first create a text field as you normally would, and on the "Options" tab of the "Text Field Properties" window, deselect all of the options and then select "Comb of" and specify how many characters (boxes) you want for the field. You will have to adjust the field size and font size to suit your needs. Note that comb fields are new to Acrobat 6.

If this isn't an option for some reason, I can post a sample PDF that demonstrates another technique, is more backward compatible, and doesn't suffer from a clunky user interface.

George