var stmp_a = "";
function strTrans_a(strT)
{
if(strT.value==stmp_a) return;
var ms = strT.value.replace(/[^\d\.]/g,"").replace(/(\.\d{3}).+$/,"$1");//验证用户的输入
var txt = ms.split("."); //分割成数组
while(/\d{4}(,|$)/.test(txt[0]))
txt[0] = txt[0].replace(/(\d)(\d{3}(,|$))/,"$1,$2"); //科学计数法表示形式
strT.value = stmp_a = txt[0]+(txt.length>1?"."+txt[1]:"");
}
这个代码是显示 数字的代码
但他有个功能就是整数以前的数,每隔三个数就会出现一个 逗号,我想不让他显示逗号
应该改哪里啊!谢谢
function strTrans_a(strT)
{
if(strT.value==stmp_a) return;
var ms = strT.value.replace(/[^\d\.]/g,"").replace(/(\.\d{3}).+$/,"$1");//验证用户的输入
var txt = ms.split("."); //分割成数组
while(/\d{4}(,|$)/.test(txt[0]))
txt[0] = txt[0].replace(/(\d)(\d{3}(,|$))/,"$1,$2"); //科学计数法表示形式
strT.value = stmp_a = txt[0]+(txt.length>1?"."+txt[1]:"");
}
这个代码是显示 数字的代码
但他有个功能就是整数以前的数,每隔三个数就会出现一个 逗号,我想不让他显示逗号
应该改哪里啊!谢谢
function strTrans_a(strT)
{
if(strT.value==stmp_a) return;
var ms = strT.value.replace(/[^\d\.]/g,"").replace(/(\.\d{3}).+$/,"$1");//验证用户的输入
var txt = ms.split("."); //分割成数组
while(/\d{4}(,|$)/.test(txt[0]))
txt[0] = txt[0].replace(/(\d)(\d{3}(,|$))/,"$1$2"); // replace中把逗号去掉就行了。
strT.value = stmp_a = txt[0]+(txt.length>1?"."+txt[1]:"");
}
function strTrans_a(strT)
{
if(strT.value==stmp_a) return;
var ms = strT.value.replace(/[^\d\.]/g,"").replace(/(\.\d{3}).+$/,"$1");//验证用户的输入
strT.value = stmp_a = ms;
}