Skip to content

Configuration options ​

Multiple configuration options allows you to customize precisely how a form <input> element will format your keystrokes as you type.
You can check what are the predefined choices for each option as well as a more detailed explanation of how they work on the official documentation page.

You can also generate your custom options object and try those live with the AutoNumeric configurator.

Want to know more? Check out the examples.

Options ​

Below are listed in alphabetical order the options that you can pass an AutoNumeric element, in order to make it change its behavior or formatting specifications.

OptionDescriptionDefault Value
allowDecimalPaddingAllow padding the decimal places with zeros. If set to 'floats', padding is only done when there are some decimals (up to the number of decimal places from the decimalPlaces variable). If set to an integer, padding will use that number for adding the zeros. If set to true it will always pad the decimal places with zeroes, and never if set to false.true
alwaysAllowDecimalCharacterDefines if the decimal character or decimal character alternative should be accepted when there is already a decimal character shown in the element.false
caretPositionOnFocusDetermine where should be positioned the caret on focusnull
createLocalListDetermine if a local list of AutoNumeric objects must be kept when initializing the elements and otherstrue
currencySymbolDefines the currency symbol to display''
currencySymbolPlacementPlacement of the currency sign, relative to the number shown (as a prefix or a suffix)'p'
decimalCharacterDecimal separator character'.'
decimalCharacterAlternativeAllow to declare an alternative decimal separator which is automatically replaced by the real decimal character when entered (This is useful in countries where the keyboard numeric pad has a period as the decimal character)null
decimalPlacesDefines the default number of decimal places to show on the formatted value, and to keep as the precision for the rawValue. This can be overridden by the other decimalPlaces* options.2
decimalPlacesRawValueDefines how many decimal places should be kept for the raw value. This is the precision for float values.null
decimalPlacesShownOnBlurThe number of decimal places to show when unfocusednull
decimalPlacesShownOnFocusThe number of decimal places to show when focusednull
defaultValueOverrideHelper option for the ASP.NET-specific postback issuenull
digitalGroupSpacingDigital grouping for the thousand separator'3'
digitGroupSeparatorThousand separator character','
divisorWhenUnfocusedDefines the number that will divide the current value shown when unfocusednull
emptyInputBehaviorDefines what to display when the input value is empty (possible options are null, focus, press, always, min, max, zero, number, or a string representing a number)'focus'
eventBubblesDefines if the custom and native events triggered by AutoNumeric should bubble up or nottrue
eventIsCancelableDefines if the custom and native events triggered by AutoNumeric should be cancelabletrue
failOnUnknownOption This option is the 'strict mode' (aka 'debug' mode), which allows autoNumeric to strictly analyse the options passed, and fails if an unknown options is used in the options object.false
formatOnPageLoadDetermine if the default value will be formatted on initializationtrue
formulaModeDefines if the formula mode can be activated by the userfalse
historySizeDetermine how many undo states an AutoNumeric object should keep in memory20
isCancellableDetermine if the user can 'cancel' the last modifications done to the element value when using the Escape keytrue
leadingZeroControls the leading zero behavior (possible options are allow, deny and keep)'deny'
maximumValueThe maximum value that can be entered (10 trillions by default)'10000000000000'
minimumValueThe minimum value that can be entered (-10 trillions by default)'-10000000000000'
modifyValueOnUpDownArrowDetermine if the element value can be incremented / decremented with the up and down arrow keys. The keys behavior is modified with the upDownStep option.true
modifyValueOnWheelDetermine if the element value can be incremented / decremented with the mouse wheel. The wheel behavior is modified with the wheelStep option.true
negativeBracketsTypeOnBlurAdds brackets [], parenthesis (), curly braces {}, chevrons <>, angle brackets 〈〉, Japanese quotation marks 「」, half brackets ⸤⸥, white square brackets ⟦⟧, quotation marks ‹› or guillemets «» on negative values when unfocused. The value must be formatted like '<leftBracket>,<rightBracket>'.null
negativePositiveSignBehaviorDefines if the negative sign should be toggled when hitting the negative or positive key multiple timesfalse
negativePositiveSignPlacementPlacement of negative/positive sign relative to the currency symbol (possible options are l (left), r (right), p (prefix) and s (suffix))null
negativeSignCharacterDefines the negative sign character to use'-'
noEventListenersDefines if the element should have event listeners activated on it.
Note: Setting this to true will prevent any format to be applied once the user starts modifying the element value. This is unlikely what you want.
false
onInvalidPasteManage how autoNumeric react when the user tries to paste an invalid number (possible options are error, ignore, clamp, truncate or replace)'error'
outputFormatDefines the localized output format of the getLocalized, form*, formArray* and formJson* methodsnull
overrideMinMaxLimitsOverride minimum and maximum limits (possible options are ceiling, floor, ignore and invalid)null
positiveSignCharacterDefines the positive sign character to use (Note: It's only shown if showPositiveSign is set to true)'+'
rawValueDivisorDefine the number that will divide the formatted value into the raw value (i.e. when displaying '1.23%', the raw value kept is 0.0123 if rawValueDivisor is set to 100)null
readOnlyDefines if the element (<input> or another allowed html tag) should be set as read-only on initializationfalse
roundingMethodMethod used for rounding. The possible options are:
S (Round-Half-Up Symmetric (default)),
A (Round-Half-Up Asymmetric),
s (Round-Half-Down Symmetric (lower case s)),
a (Round-Half-Down Asymmetric (lower case a)),
B (Round-Half-Even 'Bankers Rounding'),
U (Round Up 'Round-Away-From-Zero'),
D (Round Down 'Round-Toward-Zero' - same as truncate),
C (Round to Ceiling 'Toward Positive Infinity'),
F (Round to Floor 'Toward Negative Infinity'),
N05 (Rounds to the nearest .05 (same as 'CHF' used in v1.9.* and still valid)),
U05 (Rounds up to next .05),
D05 (Rounds down to next .05)
'S'
saveValueToSessionStorageAllow the decimalPlacesShownOnFocus value to be saved into session storagefalse
selectNumberOnlyDetermine if the 'Select All' keyboard command will select the complete input text content (including the currency symbol and suffix text), or only the input numeric valuefalse
selectOnFocusDefines if the element value should be selected on focus. That selection is dependent on the selectNumberOnly option value.true
serializeSpacesDefines how the serialize functions should treat spaces when serializing (convert them to '%20' or '+')'+'
showOnlyNumbersOnFocusRemove the thousand separator, currency symbol and suffix on focusfalse
showPositiveSignAllow the positive sign symbol + to be displayed for positive numbersfalse
showWarningsDefines if warnings should be shown. This is safe to disable in production.true
styleRulesDefines the rules that calculate the CSS class(es) to apply on the element, based on the raw unformatted value.
This can also be used to call callbacks whenever the rawValue is updated.
null
suffixTextAdditional text suffix that is added after the number''
symbolWhenUnfocusedSymbol placed as a suffix when unfocused. This is used in combination with the divisorWhenUnfocused option.null
unformatOnHoverDefines if the element value should be unformatted when the user hover his mouse over it while holding the Alt keytrue
unformatOnSubmitRemoves formatting on submit eventfalse
upDownStepUsed in conjonction with the modifyValueOnUpDownArrow option, this allows to either define a fixed step (i.e. 1000), or a progressive one that is calculated based on the size of the current value'1'
valuesToStringsProvide a way for automatically and transparently replacing the formatted value with a pre-defined string, when the raw value is equal to a specific value.
For instance when using { 0: '-' }, the hyphen '-' is displayed when the rawValue is equal to 0. Multiple 'replacements' can be defined.
null
watchExternalChangesDefines if the AutoNumeric element should watch (and format) external changes made without using .set(). This is set to false by default to prevent infinite loops when used with third party frameworks that relies on the 'autoNumeric:rawValueModified' events being sent.false
wheelOnUsed in conjonction with the modifyValueOnWheel option, defines when the wheel event will increment or decrement the element value, either when the element is focused, or hovered'focus'
wheelStepUsed in conjonction with the modifyValueOnWheel option, this allows to either define a fixed step (i.e. 1000), or a progressive one that is calculated based on the size of the current value'progressive'