gpt4 book ai didi

java - 根据用户输入在文本框 asp.net 中自动添加货币值(value)分 (12,345.00 , 12,345.55)

转载 作者:太空宇宙 更新时间:2023-11-04 12:31:18 25 4
gpt4 key购买 nike

我的这段代码在处理逗号货币位值时效果很好。用户输入后,它会自动添加一个逗号 (12,345)。这是代码:

<script type="text/javascript" language="javascript">

function Comma(Num) {
Num += '';
Num = Num.replace(',', ''); Num = Num.replace(',', ''); Num = Num.replace(',', '');
Num = Num.replace(',', ''); Num = Num.replace(',', ''); Num = Num.replace(',', '');
x = Num.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1))
x1 = x1.replace(rgx, '$1' + ',' + '$2');
return x1 + x2;
}

</script>

但我想要发生的是在货币值末尾添加 .00。 (12,345.00) 您想分享任何技巧或引用吗?

更新 typed in 1, two zeroes become visible. then i typed in another 1's, it goes after the zeroes

最佳答案

您可以使用 jQuery FormatCurrency 插件: http://code.google.com/p/jquery-formatcurrency/

关于java - 根据用户输入在文本框 asp.net 中自动添加货币值(value)分 (12,345.00 , 12,345.55),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37832138/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com