Special options
noEventListeners
Using the noEventListeners
option allows AutoNumeric to apply formatting without adding any event listeners to an input, or any other DOM elements (that the function would accept as a parameter).
This would be useful for read-only values for instance.
// Initialize with setting up event listeners, but removing them in the same call
anElement = new AutoNumeric(domElement, 12345.789, { options }).remove(); // This is the default existing way of doing that...
// Initialize without setting up any event listeners by directly passing the special option `noEventListeners` to prevent the initial creation of those event listeners
anElement = new AutoNumeric(domElement, 12345.789, { noEventListeners: true });
Note
The value can then be formatted via a call to set()
.
readOnly
AutoNumeric can initialize an <input>
element with the readonly
property by setting the readOnly
option to true
in the settings:
For more detail on how to use each options, please take a look at the detailed comments in the source code for the AutoNumeric.defaultSettings
object.