Skip to Main Content
Feature Request FR-4078
Product Area Page Components
Status CLOSED

1 Voters

Million format in text/number field

ruhulamin34 Public
· Oct 24 2024

Idea Summary:

The goal is to enhance the readability of numeric inputs and calculated fields by applying a format mask (such as commas for thousands, decimal points, etc.) during the input phase itself, rather than relying on backend formatting like to_char.

Use Case:

  • During Input: When users enter numbers, they should be formatted in real time to improve readability (e.g., 5,000 instead of 5000).
  • Calculated Fields: Once the number is processed and any calculations are done, the resulting value should also be displayed with formatting.

Preferred Solution:

You could use libraries or mask properties that provide real-time formatting for numbers without altering the underlying data type or structure. Some JavaScript or framework-based options include:

1. JavaScript Libraries:

  • **Inputmask.js**: This library provides input masks for various formats, including currency, percentage, and numeric formats.
  • **autoNumeric**: It automatically formats input fields to display numbers with comma separators, decimal points, and more while keeping the number valid for calculations.

2. HTML Input Element with Pattern/Masking:

  • You can also apply a custom pattern for input fields using pattern attributes or oninput event listeners to format numbers dynamically as users type.

3. React/Angular Libraries:

  • For frameworks like React or Angular, there are specific libraries like react-number-format or ngx-mask to easily integrate number formatting during input.

This method avoids the backend manipulation (e.g., using to_char(5000, '999G990D00')) by keeping the number format in place on the client-side while maintaining the numeric type for calculations.

 Oracle APEX, 

Approach 1: Using the Format Mask in Oracle APEX

  1. Create a Text Field item in your form where users will input numbers.
  2. Under the Settings section for the item, locate the Format Mask property.
  3. You can apply a predefined format mask, for example:
    • 999G999G999 for grouping with commas
    • 999G990D00 for decimals with thousands grouping

This mask will ensure the number is displayed in the formatted way after submission, but for real-time formatting as users type, you need an additional step.

Approach 2: Real-Time Formatting Using JavaScript (autoNumeric)

Oracle APEX allows you to inject JavaScript for real-time input formatting. Using autoNumeric.js, you can format input fields without changing the underlying numeric type.

Include the autoNumeric library in Oracle APEX:

  • Go to Shared Components > Static Application Files.
  • Upload the autoNumeric.min.js file (you can download it from autoNumeric).

Add JavaScript to Format the Input Field:

  • In your page, navigate to the Text Field for number input.
  • Under the Advanced section, add a static ID to the field, e.g., P1_NUMBER_FIELD.

Add Dynamic Action for JavaScript Execution:

  • Go to Dynamic Actions and create a new one.
  • Set the Event to Page Load or After Refresh.
  • Under True Actions, add Execute JavaScript Code, and use the following code:

Approach 3: Use Input Masks (Without JavaScript)

Alternatively, you can use the built-in Input Mask functionality in APEX:

  1. Select your number field in the APEX page designer.
  2. Under Settings, locate the Input Mask attribute.
  3. Apply a mask like:
    • 999,999,999 for commas.
    • Custom masks can be added to control decimals or other formats.

However, the built-in Input Mask is more rigid than a JavaScript-based solution and may not handle all formatting requirements dynamically.

This request is likely a duplicate of FR-3035.

Comments

Comments

  • fac586 OP 5 weeks ago

    More AI hallucination.

    “Approach 1” says that currently APEX does not meet the OP's requirement:

    Approach 1: Using the Format Mask in Oracle APEX

    2. Under the Settings section for the item, locate the Format Mask property.

    This mask will ensure the number is displayed in the formatted way after submission, but for real-time formatting as users type, you need an additional step.

    However this is contradicted by “Approach 3” which describes “built-in” functionality that does:

    Approach 3: Use Input Masks (Without JavaScript)
    Alternatively, you can use the built-in Input Mask functionality in APEX:
    Select your number field in the APEX page designer.
    Under Settings, locate the Input Mask attribute.

    Those with any actual familiarity with APEX will recognise that the OP's AI of choice has completely made “Approach 3” up, because the “Input Mask” attribute does not exist.

    Maybe it's managed to get a preview of APEX 24.2…

  • fac586 OP 5 weeks ago

    The goal is to enhance the readability of numeric inputs and calculated fields by applying a format mask (such as commas for thousands, decimal points, etc.) during the input phase itself

    Duplicate of FR-3035