function addingCommasToControl(stringVariable)
{
stringVariable += '';
k = stringVariable.split('.');
k1 = k[0];
k2 = k.length > 1 ? '.' + k[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
k1 = k1.replace(rgx, '$1' + ',' + '$2');
}
return k1 + k2;
}
The above function will add commas to the control
Example :
Name : txtPrice
Control : TextBox
so in the html or in design part of .net you can write as
onblur of the txtPrice textbox the user can able to call the addingCommasToControl() function
the parameter the user should pass is the amount
so when the user enters 124573.00
then on blur of the textbox the output will be displayed in the textbox is 1,24,573.00
Hope this may helps you
Kumar