Format Number in Currency using javascript


Now you can convert your number in currency format using the below function.

function formatNumber(number) {
number=number+'';
return number.replace(/[^d.-]/g,'').replace(/(.d{2})[Ww]+/g,
'$1').split('').reverse().join('').replace(/(d{3})/g, '$1,').
split('').reverse().join('').replace(/^([-]{0,1}),/, '$1').
replace(/(.d)$/, '$1'+'0').replace(/.$/, '.00');
}
Advertisements

4 thoughts on “Format Number in Currency using javascript

  1. Hello, Neat post. There’s a problem together with your site in web explorer, could check this? IE still is the market leader and a huge component of folks will leave out your excellent writing because of this problem.

  2. Thank you for some other wonderful post. The place else may anybody get that kind of info in such a perfect method of writing? I’ve a presentation next week, and I’m at the search for such information.

  3. I will right away take hold of your rss as I can’t in finding your e-mail subscription hyperlink or newsletter service. Do you’ve any? Please allow me understand so that I may just subscribe. Thanks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s