在VS.net2005,textbox输入数字,自动实时显示千位分隔符!!!
如题,textbox1里面,输入100000,自动变为100,000千位分隔符!!而且不要出现我一输入数字自动会出现小数点以及后面两位,如:5.00,然后光标会自动跳到数字的最前面
求救!
------解决方案--------------------
<script>
function cc(s){
if(/[^0-9\.]/.test(s)) return "invalid value";
s=s.replace(/^(\d*)$/,"$1.");
s=(s+"00").replace(/(\d*\.\d\d)\d*/,"$1");
s=s.replace(".",",");
var re=/(\d)(\d{3},)/;
while(re.test(s))
s=s.replace(re,"$1,$2");
s=s.replace(/,(\d\d)$/,".$1");
return s.replace(/^\./,"0.")
}
</script>
<input onchange="this.value=cc(this.value)">