Skip to main content
Participant
September 5, 2017
Answered

Use Space instead of Decimals

  • September 5, 2017
  • 1 reply
  • 827 views

Hi,

I want to use space instead decimal as a separator without affecting its calculation.
For Example, 10,590.24 should be 10,590 24

Thanks

Correct answer Tariq Dar

Hi Anmols,

Sorry for the delay in response.

You may try: Once you place a field on the form>Field properties>Format tab, from the drop-down "Select format category" and choose the predefined ones or choose custom. https://helpx.adobe.com/acrobat/using/pdf-form-field-properties.html#format_tab_for_form_field_properties

Let us know if that helps.

-Tariq Dar

1 reply

Tariq DarCorrect answer
Legend
November 2, 2017

Hi Anmols,

Sorry for the delay in response.

You may try: Once you place a field on the form>Field properties>Format tab, from the drop-down "Select format category" and choose the predefined ones or choose custom. https://helpx.adobe.com/acrobat/using/pdf-form-field-properties.html#format_tab_for_form_field_properties

Let us know if that helps.

-Tariq Dar

Inspiring
July 22, 2024

I, too, am looking to use a space instead of a decimal point in all dollar amount fields on a form.  The predefined options in Format > Number do not have this option.  How would I code to do this?

Example:

User types:                                              Display as:

    Line 1:  165.25                                          165 25

    Line 2:  64.98                                            64 98

    Line 3 auto-calculate Line 1 minus Line 2 and display as:    100 27

 

I have the calculation part working fine, it's just changing the decimal point to a space without it affecting the calculations that I need help with.  My forms have a hard-coded decimal point on them and the two decimal points (one on the form and one in the data field) are causing problems in processing.  Changing the form to remove the hard-coded decimal point is not an option at this time.  I've tried to line up the decimal points and cannot get it exact for all users.

Souvik Sadhu
Community Manager
Community Manager
January 9, 2025

Hi @kathyb80271993,

 

Hope you are doing well. Thanks for writing in!

 

If you are still looking for a solution, here’s how you can achieve this:

Step 1: Configure the Field Format with a Custom Script

  1. Open the form in Acrobat.
  2. Select the field you want to format.
  3. Open Properties (right-click the field and choose "Properties").
  4. Go to the Format tab.
  5. Select Custom Format Script and enter the following
if (!isNaN(event.value) && event.value !== "") {
    // Replace the decimal point with a space in the displayed value
    event.value = event.value.toString().replace(".", " ");
}

Step 2: Ensure Calculations Are Not Affected

For fields that involve calculations:

  1. Perform all calculations using the numeric values (with decimal points) in JavaScript.
  2. Use a Custom Format Script in the fields displaying the results to apply the formatting.

Example for an auto-calculated field:

  1. Go to the Calculate tab of the field where the result is displayed.
  2. Add your calculation (e.g., Line 1 - Line 2).
  3. Then, in the Format tab, use the same custom script to replace the decimal point with a space:
    if (!isNaN(event.value) && event.value !== "") {
        event.value = event.value.toString().replace(".", " ");
    }
    

Step 3: Optional - Validate Input

To ensure users always enter values with two decimal places:

  1. Go to the Validate tab.
  2. Use the following script to validate the input:
    if (!/^\d+(\.\d{2})?$/.test(event.value)) {
        app.alert("Please enter a valid dollar amount with two decimal places.");
        event.rc = false;
    }
    

To be Noted:

  1. Hard-Coded Decimal Points on the Form: The script ensures that only the display value is affected. Calculations and data processing will continue to use the standard numeric format with the decimal point.
  2. Alignment Issues: Using a space instead of a decimal point might cause slight misalignment if the font in the form fields doesn’t handle spaces and numbers uniformly. Test with different fonts or field alignment options to improve visual consistency.

This approach keeps the decimal-based calculations functional while presenting the values with space as required.

 

Let me know if you need further assistance!


-Souvik