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

Help! Problem with backspace on auto tabbing!

Steve Wiskowski
Registered: Jun 29 2010
Posts: 9

Hello! I have a strange problem that I hope someone can shed a light on for me. I have created some forms on a PDF document where I needed them to auto tab to the next form box after the alotted characters are reached. That part works great with the keystroke script I am using! The problem is that when you click on a form box to edit, you can only backspace a few characters before it automatically takes me to the next box. Here is the keystroke script I am using...

l=event.value.length;
if (l==10)
getField("A.0.1").setFocus();

The (l==10) portion represents the 11 allowed characters in the line before automatically tabbing to the next box, which is "A.0.1" Do I need to add some additional code to this script to fix the backspace issue?

Help!!!
Steve

My Product Information:
Acrobat Pro 8.1.2, Macintosh
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Have you looked for any other scripts to preform this task?

You could have done a search for 'autotab' and found lots of posts.

[url=http://www.planetpdf.com/developer/article.asp?ContentID=javascript_setfocus_method_f&gid=6267]JavaScript - setFocus Method for tabbing to next form field[/url] by Carl Orthlieb uses the function call 'AFMergeChange(event)' to obtain the character count including the current keystroke which has the actual key count prior to exiting the field, while the 'event.value.length' only has the length value prior to the current keystroke.

George Kaiser

Steve Wiskowski
Registered: Jun 29 2010
Posts: 9
Thanks for the assistance! I did an extensive search for scripts, but could not find anything regarding the backspace problem. The link you gave me shows a sample that works great, but the code works on numerical characters, not alphabetical characters. I either need to find another keystroke script or add code to the one I am using.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You only need to remove the reference to the 'AFNumber_Keystroke' funciton and 'event.rc' format checking.
function AutoTab(doc, event, cNext){function AutoTab(doc, event, cNext){// Call the built-in routine to allow numbers only.// or add validation function that returns and logical value to 'event.rc' for validation result// event.rc is true by default// AFNumberfunction_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();}}

George Kaiser

Steve Wiskowski
Registered: Jun 29 2010
Posts: 9
Thanks again! Do I just copy and paste this entire code into the custom keystroke script box? I'm more a designer than a programmer, so this is a little confusing.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You need to copy the entire script to a document level script.

[url=http://www.acrobatusers.com/tutorials/2007/07/js_document_scripts]Entering Document Scripts[/url] by Thom Parker
[url=http://www.acrobatusers.com/tutorials/2006/where_js_goes]So where does JavaScript live in Acrobat?[/url] by Thom Parker

George Kaiser