Objective
When doing financial projects, a large number of contacts of digital strings often need to be formatted to display, here I wrote a demo, the string amount is formatted, you can retain the number of decimal digits, you can add a currency identifier prefix.
Written in the prototype string, you need to format the right time to format the chant!
Example: ' 123345.23123 '. Moneyformatter (2, ' ¥ ')
Output: ' ¥123,345.23 '
The demo has a comment, so I don't have to do any more explaining.
My demo
<! DOCTYPE html>Brief introductionAccept two parameters, N and current, do not pass the process, if you want to pass in the specified order, first pass n,n to need to retain a few decimals, and then pass the current as if you want to add a currency prefix directly into!
Method internal default is the standard Money presentation form, 3 bit a ', ', will no longer be flexible control of parameters!
Convert string amount to currency format in the specified format