lagden / currency

The simple and tiny script for currency input mask
https://codepen.io/lagden/pen/jOrZVjg?editors=1010
MIT License
16 stars 2 forks source link

The Intl.NumberFormat options not working #2

Closed mccarlosen closed 1 year ago

mccarlosen commented 1 year ago

Hi! I am using this library. But I have a question.

How can I change the decimal separator from , to .?

Example: from 1.234,56 to 1234.56.

new Currency(this.element, {
    maskOpts: {
        locales: "es-ES",
    options: {
            decimal: "."
        }
    }
})
lagden commented 1 year ago

Hi!

const maskOpts = {
  locales: 'en-US',
  options: {
    useGrouping: false,
    minimumFractionDigits: 2,
    maximumFractionDigits: 2,
  },
}

// static
Currency.masking('1.234,56', maskOpts) // => 1234.56

// instance
new Currency(input, {maskOpts})

You can see here for more options: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#syntax