cents-input

1.0.4 • Public • Published

Cents Input

Handle money with cents input when it must start filling from decimal part.

Example:

A keyboard with money value being inputed


How to use it

First, install cents-input package:

npm i cents-input

Then import it in your project:

import CentsInput from 'cents-input';

Create an instance of the CentsInput class:

const instance = new CentsInput();

Options

You can set a prefix and separator as options:

const instance = new CentsInput({
  prefix: 'R$ ', // default is empty
  separator: '.',  // default is comma
});

Methods

There are some methods available:

instance.addDigit(1);

Add a digit to the current value. Put the value you want to add as a parameter.

instance.removeDigit();

Remove a digit from the end of the current value.

instance.getFormatted();

Return the formatted value, including the prefix.

instance.getFloat();

Return the float value, without the prefix.

instance.reset();

Reset the value.

/cents-input/

    Package Sidebar

    Install

    npm i cents-input

    Weekly Downloads

    5

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    3.21 kB

    Total Files

    4

    Last publish

    Collaborators

    • hevertoncastro