How to Allow a Dash in Acrobat Numeric Form Fields
Question details
The user needs to allow and visually display a dash (-) in numeric PDF form fields to indicate a missing value, without causing calculation errors.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Setting up arithmetic calculations in a PDF form where some fields might be left empty or marked with a dash to represent missing data.
- Observed behavior
- Using the Number() function directly on a dash character results in a NaN (Not a Number) error, which breaks the subsequent form field calculations.
Ensure your PDF editing software allows you to access form field properties and that you have basic familiarity with entering custom JavaScript for field formatting.
Use a Custom Format Script to Display a Dash
Instead of passing a dash into the calculation, treat empty values as zero and use a format script to visually display the dash to the user.
By separating the underlying numeric calculation from the visual formatting, you ensure that JavaScript always receives valid numbers (like zero) for its math operations while still meeting the visual requirements of the form.
Enter form editing mode in your PDF editor, right-click the target numeric field, and select Properties from the context menu.
In the Calculate tab, write your script to check for empty values and treat them as 0 rather than parsing them directly. For example, assign 0 to your variable if the field is blank.
Navigate to the Format tab, choose 'Custom' from the category list, and enter a script that checks if the field's value is 0. If it is, script it to display a '-' string instead of the number 0.

Validate and Replace Dash Input Automatically
Intercept the dash character as it is typed by the user and convert it to a zero before any calculations occur.
Create and Manage Interactive PDF Forms with WPS Office
WPS PDF provides a streamlined, intuitive interface for creating, editing, and managing interactive PDF forms. You can easily insert text fields, numeric inputs, and handle document calculations without needing complex scripting experience.
- 1. Open WPS PDF: Launch WPS Office and open your PDF document using the built-in WPS PDF editor.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to view all available interactive form control options.
- 3. Add Form Fields: Select 'Text Field' or 'Number Field' to insert new elements into your document.
- 4. Edit Field Properties: Double-click the inserted field to modify its properties, set default values, and configure how data should be handled.

Frequently Asked Questions
Why does JavaScript return NaN when calculating a dash in a PDF form?
JavaScript's Number() function expects standard numerical digits. Because a dash (-) is interpreted as a string character or a minus operator rather than a digit, the function cannot parse it, resulting in a Not-a-Number (NaN) error.
Can I still use a minus sign to input negative numbers?
Yes. A minus sign placed directly in front of a number (e.g., -5) is recognized as a valid negative number. The NaN error only occurs when a dash is used in isolation to represent a blank or missing value.
Will a custom format script alter the actual exported value of the form field?
No. A custom format script only changes how the data is visually presented on the screen or when printed. The underlying calculated value (e.g., 0) remains unchanged, ensuring data integrity when exporting the form data.




