live-number-formatter
v0.0.8
Published
a live number formatter
Maintainers
Readme
live-number-formatter
currently (beta)
Is an input field for numbers that formats the entered number live.
demo
go to the demo >>

usage
pnpm add live-number-formatterimport LiveNumberFormatter from 'live-number-formatter';
const numberField = document.querySelector('#numberField');
const options = {
prefix: '$ ',
}; // see below
const lnf = new LiveNumberFormatter(numberField, options);options
const options = {
// the startValue, will be set at initialization
startValue: null,
// the number prefix, e.g.: '€ '
prefix: null,
locale: 'en-US',
// the min value
min: null,
// the max value
max: null,
// shot the prefix if the field is empty
showAffixWhenEmpty: false,
// allow comma numbers, e.g.: 12.4
allowComma: true,
// max number of decimal Places
maxDecimalPlaces: 2,
};