I am trying to convert a float from one culture to another, and seems nothing i found online was working for me. The problem is:
- I have a parameter coming from external resource (web service) in a specific culture.
- the result is send to an MVC application, and VALIDATED depending on the current culture settings.
this means i have to somehow convert from the static culture ("en-US") to whatever is selected ON THE CLIENT, before the data is sent to the server for processing, so all the data from the client is on one culture.
I believed that Globalization jQuery plugin (GitHub) will provide this functionality for formatting numbers (and dates) in given culture out-of-the-box, but it seems it do not.
What i tried:
using the Globalization plugin, setting Globalize.culture
property, and hoping that Globalize.format(Globalize.parseFloat("1.2435677777", 10, "en-US")))
will format the value with the desired decimal separator. However it seems it does not worked for me.
If anyone can point what i did wrong, and give a better working example - will be great.