这是我的 Javascript:
<script type = "text/javascript" language = "javascript">
function formatCurrency(num) {
num = num.toString().replace(/\Rs.|\,/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>
我正在使用这个脚本在文本框中格式化货币。它适用于所有启用的文本框,但不适用于禁用的文本框,因为在某些事件中文本框中的数量相同。
下面是我的文本框:
<asp:TextBox ID="txtToTSanctioned" runat="server" Text="00.00"
CssClass="mytextbox" Enabled="False"
onblur = "this.value=formatCurrency(this.value);"></asp:TextBox>
解决方案是什么?