Copy link to clipboard
Copied
I’m trying to speed up the process of creating an interactive pdf form in Adobe Acrobat through Action Wizard using Javascript, as I use and change the forms many times a day. I’m struggling to make the auto tab work through Action Wizard – I have some fields that require only one number and I like it to automatically go to the next field once that number is entered. Example of some of the code I currently use in Action Wizard:
for (var i = 0; i < numFields; i++) {
var fName = getNthFieldName(i);
var f = getField(fName);
var fTool = getNthFieldName(i).userName;
if (fName == "C1”) {
f.charLimit = 1;
f.alignment = "center";
f.setAction("Keystroke", "AFNumber_Keystroke\(0, 0, 0, 0, \"\", false\);");
}
if (fName =="C2”) {
f.charLimit = 1;
f.alignment = "center";
f.setAction("Keystroke", "AFNumber_Keystroke\(0, 0, 0, 0, \"\", false\);");
}
}
So I would like C1 to have some code that automatically goes to C2. Is there any way this is possible with just Action Wizard? Currently I’ve been doing it manual using:
function tab_next(next_field_name) {
if (event.willCommit || AFMergeChange(event).length === event.target.charLimit) {
getField(next_field_name).setFocus();
}
}
And the Keystroke script:
tab_next(“C2”);
If anyone knows a way to do this, that would be much appreciated. Thanks!
Copy link to clipboard
Copied
You'd have to create a new document-level function that combines what the AFNumber_Keystroke routine accomplished as well as the tab_next routine, something like:
// Document-level function
function digOnlyKS_TabNext(next_field_name) {
// Get all that is currently in the field
var val = AFMergeChange(event);
// Reject entry if anything but digits
event.rc = AFExactMatch(/\d*/, val);
if (event.rc && next_field_name) {
if (event.willCommit || AFMergeChange(event).length === event.target.charLimit) {
getField(next_field_name).setFocus();
}
}
}
You'd then like this in the keystroke event:
// Auto tab to C2
digOnlyKS_TabNext("C2");
and for the C2 field:
digOnlyKS_TabNext();
Find more inspiration, events, and resources on the new Adobe Community
Explore Now