Search code examples
javascripttextmask

Javascript Currency Mask on Plain Text


I have this screen where I my user type a currency value on a Input element. When I save it on my Database, it goes like a text. Ie: 10000.

I am trying to show this value in another screen with a currency mask like $10.000 but I don´t want to use a input field. I am just showing the value inside a <ul> .

How do I do that with Javascript???


Solution

  • Using

    .toLocaleString('pt-BR', { style: 'currency', currency: 'BRL' })
    

    did the trick.