I have a javascript code which conver the amount in to US format the same i would like to have in code behind can any one help me..
<script type="text/javascript">
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}
</script>
Or if there is any easier method tell me. My actual requirement is to sum the two given amounts in the text boxes and to display the amount in 3rd text box.
For example if i have my 1st value as 123.12 by the above script i will get the display in my text box as $123.12 and second as same to $123.12 the output should be $246.23
can any one help me
There is a standard formatting for currency:
Ouptut:
The standard for negative currency values is however to display it within parentheses, so if you want a negative sign instead you have to modify the culture:
Ouptut: