How to Create PDF Comb Fields with Spacing and Automatic Tab Order
Question details
The user needs to group number entries in a PDF form with visible spacing between sets and automatically move the typing focus to the next field when the current comb field is filled.

- Product
- Device & OS
- not provided
- Scenario
- Creating advanced interactive PDF forms for structured data inputs like phone numbers, Social Security numbers, or credit card details.
- Observed behavior
- The goal state is to have visually separated blocks of comb fields where reaching the maximum character count of one block automatically triggers a jump to the subsequent field.
Ensure you are using a comprehensive PDF editor that supports both interactive form field properties and custom keystroke JavaScript execution.
Use Separate Comb Fields with Auto-Tab JavaScript
Using separate text fields allows for precise visual spacing between number groups, while a custom script handles the automatic transition to the next field.
Since native PDF formatting doesn't automatically jump to the next object out-of-the-box, the most reliable method is dividing your input into separate comb fields and applying a short JavaScript snippet to detect the character limit.
Draw individual text fields for each specific group of numbers, leaving physical space between them on your document layout.
Right-click each text field, select 'Properties', navigate to the 'Options' tab, check the 'Comb of characters' box, and enter the exact character limit for that specific block.
Go to the 'Format' or 'Actions' tab within the field properties and select 'Custom Keystroke Script'.
Input a script that detects the length and shifts focus, for example: `if (event.value.length == 4) getField('NextField_Name').setFocus();`, adjusting the number '4' and 'NextField_Name' to match your form.

Format a Single Field with Spaced Groups
If strict distinct visual gaps between separated boxes aren't mandatory, you can use a single comb field and use a script to automatically insert spaces.
Easily Build Interactive PDF Forms with WPS Office
WPS Office offers robust PDF editing capabilities, enabling you to effortlessly insert text fields, manage comb formatting, and configure interactive form properties to streamline data entry.
- 1. Open your PDF document: Launch WPS Office and open the PDF file you wish to turn into an interactive form.
- 2. Access form tools: Navigate to the 'Form' tab on the top ribbon to view all interactive elements.
- 3. Insert text fields: Click 'Text Field' and draw the input areas directly onto your document where the number entries should go.
- 4. Adjust field properties: Right-click the newly created fields and select 'Properties' to modify character limits and formatting.

Frequently Asked Questions
What is a comb field in a PDF?
A comb field is a specific text field property in PDFs that evenly spaces the user's input across the width of the field. It separates each typed character into its own visible cell or block, which is highly useful for forms requiring precise character placement like ID numbers.
Why isn't my auto-tab JavaScript working in the PDF?
Auto-tab functions can fail if the PDF viewer has JavaScript disabled for security reasons, or if there is a typo in the target field name within the script. Additionally, some basic PDF readers on mobile devices do not support complex JavaScript executions.
Is it possible to auto-tab without using JavaScript?
No, the standard PDF form specification does not natively include an 'auto-tab to next field' setting. Implementing this behavior strictly requires adding a custom keystroke or formatting JavaScript to the field.
How do I align multiple separated comb fields perfectly?
Most advanced PDF editors offer alignment tools. You can select all your separated text fields by holding down the Ctrl or Shift key, right-click, and use the 'Align' (e.g., Align Bottom) and 'Distribute Horizontally' options to ensure even spacing.




