14,392,303 members
Rate this:
See more:
hi..
check the following code..

```<script type="text/javascript">
var indMoney = function (v)
{
v = (Math.round((v - 0) * 100)) / 100;
v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
v = String(v);
var ps = v.split('.'),
whole = ps[0],
sub = ps[1] ? '.' + ps[1] : '.00',
r = /(\d+)(\d{3})/;
while (r.test(whole))
{
whole = whole.replace(r, '\$1' + ',' + '\$2');
}
v = whole + sub;

return v;
}
</script>```

The result of the above function is displaying like this 123,123,123.00
but i want in this format 12,12,12,12,123.00 i.e indian currency format..
Posted
Updated 25-Feb-11 0:42am
v2
Comments
Richard MacCutchan 25-Feb-11 5:25am

You already posted this in the Java forum; post in one place only please.

Rate this:

## Solution 1

try this its working
``` function changeNo (v)
{
v = (Math.round((v - 0) * 100)) / 100;
v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
v = String(v);
var ps = v.split('.'),
whole = ps[0],
sub = ps[1] ? '.' + ps[1] : '.00',
r = /(\d+)(\d{2})/;
if(parseInt(whole)>999)
{
var whole1=whole.substring(whole.length-3);
var whole2=whole.substring(0,whole.length-3);
while (r.test(whole2))
{
whole2 = whole2.replace(r, '\$1' + ',' + '\$2');
}
v = whole2+','+whole1 + sub;
}
else
{
v = whole+ sub;
}
return v;
}```
Comments
vinu.1111 25-Feb-11 5:50am

thanku sir... it really helped me..
pankajupadhyay29 25-Feb-11 5:53am

welcome dear.
pankajupadhyay29 25-Feb-11 5:56am

ok mark this as answer.
--Pankaj
vinu.1111 25-Feb-11 7:27am

hi...
there's one problem
it is not showing for negative values...
what to do now

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 OriginalGriff 150 Richard MacCutchan 70 RickZeeland 70 Maciej Los 55 Patrice T 40
 OriginalGriff 2,253 Richard MacCutchan 1,063 RickZeeland 938 Richard Deeming 875 Maciej Los 740

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100