JavaScript: Format numbercurrency wregards to culture like .NET's String.Format()? - Stack Overflow

This seems like a problem someone would've already solved in the year 2009, but I can't find

This seems like a problem someone would've already solved in the year 2009, but I can't find a decent JavaScript library that will take a number like:

12345.58

And format it correctly based on a specific culture (ie, "nl-nl") or ISO currency code.

dojo showed promise, but it doesn't include many cultures by default, and actually wasn't working properly in my tests.

I basically want something that is 100% or near-100% equivalent to what .NET does for me, when I run:

String.Format([cultureInfo Object], "{0:N}", myValue) ' for numbers

and

String.Format([cultureInfo Object], "{0:C}", myValue) ' for currency

This seems like a problem someone would've already solved in the year 2009, but I can't find a decent JavaScript library that will take a number like:

12345.58

And format it correctly based on a specific culture (ie, "nl-nl") or ISO currency code.

dojo showed promise, but it doesn't include many cultures by default, and actually wasn't working properly in my tests.

I basically want something that is 100% or near-100% equivalent to what .NET does for me, when I run:

String.Format([cultureInfo Object], "{0:N}", myValue) ' for numbers

and

String.Format([cultureInfo Object], "{0:C}", myValue) ' for currency

Share Improve this question edited Oct 23, 2009 at 21:18 Nicholas Head asked Oct 23, 2009 at 20:59 Nicholas HeadNicholas Head 3,7265 gold badges29 silver badges39 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

The ASP.NET Ajax framework lets you do this.

Set the EnableScriptGlobalization property on the ScriptManager to true. You can then use the Number.localeFormat function to format numbers.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744850215a4597081.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信