If I do:
var number = 3500; alert(number.toLocaleString("hi-IN"));
I will get ३,५००
in Hindi.
But how can I convert it back to 3500
. I want something like:
var str='३,५००'; alert(str.toLocaleNumber("en-US"));
So, that it can give 3500
.
Is it possible by javascript, jquery or any other free library?
You can convert a string to a number in Node. js using any of these three methods: Number() , parseInt() , or parseFloat() .
The toLocaleString() method returns a Date object as a string, using locale settings. The default language depends on the locale setup on your computer.
The toString() method is a built-in method of the JavaScript Number object that allows you to convert any number type value into its string type representation.
I think you are looking for something like:
https://github.com/jquery/globalize
Above link will take you to git project page. This is a js library contributed by Microsoft. You should give it one try and try to use formt method of that plugin. If you want to study this plugin, here is the link for the same:
http://weblogs.asp.net/scottgu/jquery-globalization-plugin-from-microsoft
I hope this is what you are looking for and will resolve your problem soon. If it doesn't work, let me know.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With