Hi Friends,
I want to display numbers as comma separated string
(like we show amount 12,34,675.67)
I have a javascript function, which I call on onkeyup event of a textbox.
Here is that function :
function Comma(Num)
{
Num += '';
Num = Num.replace(/,/g, '');
x = Num.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1))
x1 = x1.replace(rgx, '$1' + ',' + '$2');
return x1 + x2;
}
This function gives me the amount as
123,456,984.00
Now, if I repoen my Voucher, I have formatted the textbox for amount using
.ToString("N")
which shows me the value as
12,34,67,567.00
AS you can see, there is difference in comma placings of these two functions.
How can I achieve the same format for amount ??
And it will be a lot better, if the value is rounded by two digits after decimal point.
Any help is appreciated.
Thanks,
Lok..