Copy link to clipboard
Copied
I created a PDF form to be used with a scanner input that I want to auto-tab to the next field without having to set a character limit (i.e., I want it to behave like Excel). I already have a Java script to perform the auto-tab function, but it requires a character limit. Is there a way to auto-tab without a character limit?
The first multiline script is intended to be placed in a document-level JavaScript. You have to do it this way due to a quirk in Acrobat that occurs when you use one of the built-in functions (AFMergeChange).
The second one-line script is what you place in the Keystroke script of the field.
If you don't know how to create a document-level JavaScript, post again, and include the version of Acrobat that you're using.
Copy link to clipboard
Copied
What should trigger it, then?
Copy link to clipboard
Copied
I'm not sure because I don't know how Excel works in the background. How does it know to auto-tab to the next field after something (at least 1 character) has been scanned? Is there a way to make it auto-tab after at least 1 character is scanned, or will it simply truncate everything after the 1st character?
Copy link to clipboard
Copied
Set the character limit to 1...
Copy link to clipboard
Copied
For the "on blur" action you can use the "setFocus" method of the field you want to tab to.
Copy link to clipboard
Copied
If you set the character limit to one, you won't be able to scan in more than 1 character. But you can use a custom keystroke script to check if there is at least one character entered in the field, and if so, set the focus to another field. Here's a sample script that should do what you want:
// Custom function placed in a document-level JavaScript
function SetFocusToNextField(sFieldname) {
// Get all of the characters that have been entered into this field
var sChars = AFMergeChange(event);
// If there are 1 or more characters, set the focus to the next field
if (sChars.length > 0) {
getField(sFieldname).setFocus();
}
}
And call it like this in the Keystroke event of the text field that accepts the scanned characters:
// Custom Keystroke script
SetFocusToNextField("Text2");
where "Text2" is the name of the field you want to set the focus to. Now, when one or more characters are entered into the text field, the focus will automatically be set to the specified field.
Copy link to clipboard
Copied
I'm not a software engineer, so please excuse my newbie ignorance. Are both of these scrips a Custom Keystroke Script? If so, there is only 1 box I can copy and paste the script into. How do I combine both sets of scripts?
Or, did you mean that I need to customize the 1st script as this (I bolded my modifications):
// Custom function placed in a document-level JavaScript
function SetFocusToNextField("Text2") {
// Get all of the characters that have been entered into this field
var sChars = AFMergeChange(event);
// If there are more than 1 characters, set the focus to the next field
if (sChars.length > 0) {
getField("Text2").setFocus();
}
};
Copy link to clipboard
Copied
The first multiline script is intended to be placed in a document-level JavaScript. You have to do it this way due to a quirk in Acrobat that occurs when you use one of the built-in functions (AFMergeChange).
The second one-line script is what you place in the Keystroke script of the field.
If you don't know how to create a document-level JavaScript, post again, and include the version of Acrobat that you're using.
Copy link to clipboard
Copied
Yes!! That worked!! Thank you so much for your help!!
Copy link to clipboard
Copied
Hello,
I'm new to all of this, so do I start from Custom and place this in Keystroke? I'm trying to do the same but entering the date MM/DD/YYY. Each field is separate (MM,DD,YYYY). What is Document-level Java Script? Again, I AM NEWWWWWW.
Thank you for your patience and time. Many of the old links don't work because they are old and pages have been removed.
Copy link to clipboard
Copied
Yes, that's correct. You need to apply it to each one of those fields.
Copy link to clipboard
Copied
Is this exactly what you typr into the custom JavaScript Field becaue I have several syntax errors. Please help
Copy link to clipboard
Copied
Such as?