Hi Friends,
I have a javascript function whicf I call on onkeyup event of textbox.
It has a regular expression that will format the values input by user with commas (,);
Problem with it is that, it puts comma after every third digit before decimal point.
I want it to put comma for first three digit before decimal point and then after every two digits (like we show amount).
12,34,567.8901
but it is showing like
1,234,567.8901
here is my script 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;
}
I think it has to do with that regular expression in function.
I tried using
MaskedEditorExtender
but client is not happy with it.
So please help me friends.
Any help appreciated.
Thanks,
Lok..