vinnu

vinnu

  • NA
  • 61
  • 202k

Please modify the java script for number in indian number format

Feb 25 2011 4:49 AM
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,31,23,123.00 i.e indian currency format..


Answers (3)