You first have to add a document level script that will tab to the next field when the preset character limit of the field being completed is reached. You then can enter as a custom format keystroke JavaScript the call to the function.
You can add the following document level script to provide an Auto Tab command. From Acrobat's menu bar select "Tools -> JavaScript -> Document JavaScripts...". Enter the script name as "AutoTab". Replace the system provided code with:
// ---> start code
function goNext(oItem, oEvent, cName, bAlpha) {
/* Tab to next field when field character limit is reached.
Includes alpha fields and case change.
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 number field:
goNext(this, event,"NextField");
Call for alpha with forced upper case:
goNext(this, event "AlphaNextField", true);
*/
try{ // error catcher
if (bAlpha) {
if (AFMergeChange(oEvent).length == oEvent.target.charLimit) oItem.getField(cName).setFocus();
}
else {
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
console.println("Error: " + eMsg + "\nField: " + oEvent.target.name + "\nNext Field: " + cName);
} finally { // always run
return; }
} //end // goNext
// ---> end code
Save the code and close the "JavaScripts" window.
Into each field you want to Auto Tab add one of the following scripts to the "Format" tab's "Custom Key Stroke Script" for either a numeric field or an alpha field:
// ---> start code for numeric values
goNext(this, event,"NameOfNextField");
// --> end code
// ---> start code for alpha field
goNext(this, event,"NameOfNextField", true);
// ---> end code
Replace "NameOfNextField" with the name of the next field to tab to in quotes. You will have to handle any special validation requirements for the information being inputted.
| Posted: 15 Feb 2005 06:57 AM |
|