Skip to content

How can I make the placeholder sign two characters after decimal point #47

@ghost

Description

Thank you for the library. How can I make the placeholder that comes after decimal point 2 digits? For example when user tries to write 12.35 after writing 12 and writing '.' the component automatically shows '' placeholder with one digit like this 12. . When user tries to write 12.35 he ends up writing 12.53 because it accepts one and returns back to start after the decimal point. When there are 2 decimal digits so it has to be '__' or nothing at all. Without that component unusable.
I tried to change how placeholderChar works in the source without success.

    <TextMask
                Component={TextInputAdapter}
                autoFocus={false}
                value={serializeDecimal(values.discount_amount, 'currencyinput')}
                mask={currencyMask}
                blur={e => handleDiscountChange(e.nativeEvent.text, 'amount')}
              />


   currencyMask = createNumberMask({
      prefix: '$',
      decimalSymbol: maskValues.decimalSymbol,
      thousandsSeparatorSymbol: maskValues.thousandsSeparatorSymbol,
      decimalLimit: 2,
      requireDecimal: maskValues.requireDecimal,
      suffix: maskValues.currencySuffix,
      includeThousandsSeparator: true,
      allowLeadingZeroes: false,
      allowDecimal: true,
      allowNegative: true
    });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions