s-yadav / react-number-format

React component to format numbers in an input or as a text.
MIT License
3.9k stars 410 forks source link

How to display format like "**** **** **** 1234" #787

Closed imakou closed 1 year ago

imakou commented 1 year ago

Describe the issue and the actual behavior

Hi, I'm doing a feature of displaying credit card numbers. But I need to mask the numbers from the first to the 12th digits.

Describe the expected behavior

Says, if i give defaultValue="4111 1111 1111 1234". How can I display like "**** **** **** 1234" in the input field?

Thanks!

Provide a CodeSandbox link illustrating the issue

n/a

Provide steps to reproduce this issue

n/a

Please check the browsers where the issue is seen

imakou commented 1 year ago

answer:


                        format={

                            `**** **** **** `${"4111  1111  1111  1234".slice(-4)}`

                        }