Highlighted

Auto-tab in PDF form without a character limit

Community Beginner ,
Apr 26, 2018

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?

Adobe Community Professional
Correct answer by George_Johnson | Adobe Community Professional

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.

TOPICS
PDF forms, Windows

Views

762

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Auto-tab in PDF form without a character limit

Community Beginner ,
Apr 26, 2018

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?

Adobe Community Professional
Correct answer by George_Johnson | Adobe Community Professional

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.

TOPICS
PDF forms, Windows

Views

763

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 26, 2018 0
Most Valuable Participant ,
Apr 26, 2018

Copy link to clipboard

Copied

What should trigger it, then?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2018 0
Community Beginner ,
Apr 26, 2018

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2018 0
Most Valuable Participant ,
Apr 26, 2018

Copy link to clipboard

Copied

Set the character limit to 1...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2018 0
Adobe Community Professional ,
Apr 26, 2018

Copy link to clipboard

Copied

For the "on blur" action you can use the "setFocus" method of the field you want to tab to.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2018 0
Adobe Community Professional ,
Apr 26, 2018

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 26, 2018 0
Community Beginner ,
Apr 27, 2018

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();

    }

};

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 27, 2018 0
Adobe Community Professional ,
Apr 27, 2018

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 27, 2018 0
Community Beginner ,
Apr 27, 2018

Copy link to clipboard

Copied

Yes!! That worked!! Thank you so much for your help!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 27, 2018 0
New Here ,
Jan 28, 2020

Copy link to clipboard

Copied

Is this exactly what you typr into the custom JavaScript Field becaue I have several syntax errors. Please help

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 28, 2020 0
Most Valuable Participant ,
Jan 29, 2020

Copy link to clipboard

Copied

Such as?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 29, 2020 0
New Here ,
Oct 08, 2020

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. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 08, 2020 0
try67 LATEST
Most Valuable Participant ,
Oct 08, 2020

Copy link to clipboard

Copied

Yes, that's correct. You need to apply it to each one of those fields.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 08, 2020 0