Skip to content

A tiny Javascript library that allows for real time formatting of numbers & currencies, ~1600 bytes minified + gzipped.

License

Notifications You must be signed in to change notification settings

abhinavxd/liveNumberFormat.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

liveNumberFormat.js

A tiny Javascript library that gives live as-you-type formatting to numbers & currencies, ~1600 bytes minified + gzipped.

View demo

output

Check the demo source.

Usage

npm i live-number-format

Default values for config shown below.

<input type="text"/>
let input = document.querySelector("input");
new LiveNumberFormat(input,
{
        // Options for formatStyle
        // 1. thousandLakhCrore
        // 2. thousand
        // 3. tenThousand
        formatStyle: "thousand",

        stripLeadingZeroes: false,

        allowNegative: true,

        // Max integer digits allowed.
        // defaults to Infinity
        integerScale: 20,

        // Max decimals digits allowed.
        // defaults to Infinity
        decimalScale: 7
});