if (Trim(theform.bb_jhdj.value)!="")
{
var ms = Trim(theform.bb_jhdj.value).replace(/[^\d\.]/g,"").replace(/(\.\d{7}).+$/,"$1");//验证用户的输入
var txt = ms.split("."); //分割成数组
// strT.value = txt[0]+(txt.length>1?"."+txt[1]:"");
if (txt[0].lenght>9)
{alert("请输入进货单价!");
theform.bb_jhdj.focus();
return false;}
}
===============================
bb_jhdj.value 这个值是一个numeric 类型数值,小数点前面9位数,小数点后面7位数。
上面这个代码是我想提取出 输入的数值,如果小数点前面的数字多于9位,那提交数据的时候提示报错。
可是不对!请大家帮我改改!谢谢了
{
var ms = Trim(theform.bb_jhdj.value).replace(/[^\d\.]/g,"").replace(/(\.\d{7}).+$/,"$1");//验证用户的输入
var txt = ms.split("."); //分割成数组
// strT.value = txt[0]+(txt.length>1?"."+txt[1]:"");
if (txt[0].lenght>9)
{alert("请输入进货单价!");
theform.bb_jhdj.focus();
return false;}
}
===============================
bb_jhdj.value 这个值是一个numeric 类型数值,小数点前面9位数,小数点后面7位数。
上面这个代码是我想提取出 输入的数值,如果小数点前面的数字多于9位,那提交数据的时候提示报错。
可是不对!请大家帮我改改!谢谢了
val = val.replace(/[^0-9\.]/g, "");
var txt = val.split(".");if(txt[0].length > 9) alert("请输入进货单价!");
}
自己+上trim。PS:你length写成lenght了