formcycle 8.5.0 - JavaScript for forms
    Preparing search index...

    Interface NumberFormatApiDo

    The API for performing actions on NumberFormat elements, such as changing the value or the options.

    The API is available via $.xutil.numberFormat.do.

    For example, to change the value of an element, use $.xutil.numberFormat.do.setValue(...).

    // Set the value to 12.34
    $.xutil.numberFormat.do.setValue(".tf1", 12.34);
    interface NumberFormatApiDo {
        changeOptions: (
            reference: any,
            options: Partial<NumberFormatOptions>,
        ) => void;
        setFormattedValue: (
            reference: any,
            newValue: undefined | string | number,
        ) => void;
        setValue: (reference: any, newValue: undefined | string | number) => void;
    }
    Index

    Properties

    changeOptions: (reference: any, options: Partial<NumberFormatOptions>) => void

    Updates the options of all given NumberFormat elements.

    Type declaration

      • (reference: any, options: Partial<NumberFormatOptions>): void
      • Parameters

        • reference: any

          NumberFormat elements to update.

        • options: Partial<NumberFormatOptions>

          The options to update.

        Returns void

    // Change the number of decimal places to 3
    $.xutil.numberFormat.do.changeOptions(".tf1", { decimalPlaces: 3 });

    If any element does not have an NumberFormat instance.

    setFormattedValue: (
        reference: any,
        newValue: undefined | string | number,
    ) => void

    Sets the value of all given NumberFormat elements to the given value. The value may be a number (1234.56) or a formatted string ("1234.56"). If a formatted string is given, it will be parsed according to the current formatting options.

    Type declaration

      • (reference: any, newValue: undefined | string | number): void
      • Parameters

        • reference: any

          The elements to set the value for.

        • newValue: undefined | string | number

          The value to set. Use an empty string or undefined to clear the value.

        Returns void

    // Set the value to 2000 (if decimal separator is '.')
    $.xutil.numberFormat.do.setFormattedValue(".tf1", "2.000");

    // Clear the value
    $.xutil.numberFormat.do.setFormattedValue(".tf1", undefined);

    If any element does not have an NumberFormat instance.

    setValue: (reference: any, newValue: undefined | string | number) => void

    Sets the value of all given NumberFormat elements to the given value. The value may be a number (1234.56) or a numerical string ("1234.56"), but not a formatted string (1234·56).

    Type declaration

      • (reference: any, newValue: undefined | string | number): void
      • Parameters

        • reference: any

          The elements to set the value for.

        • newValue: undefined | string | number

          The value to set. Use an empty string or undefined to clear the value.

        Returns void

    // Set the value to 12.34
    $.xutil.numberFormat.do.setValue(".tf1", 12.34);

    // Clear the value
    $.xutil.numberFormat.do.setValue(".tf1", undefined);

    If any element does not have an NumberFormat instance.