Handle money with cents input when it must start filling from decimal part.
Example:
First, install cents-input package:
npm install cents-input
or
yarn add cents-input
Then import it in your project:
import CentsInput from 'cents-input';Create an instance of the CentsInput class:
const instance = new CentsInput();You can set a prefix and separator as options:
const instance = new CentsInput({
prefix: 'R$ ', // default is empty
separator: '.', // default is comma
});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.
