function num(obj){obj.value = obj.value.replace(/[^\d.-]/g,""); //清除"数字"和"."以外的字符obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是.字obj.value = obj.value.replace(/^[0]/g,"");//验证第一个字符是0字obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个, 清除多余的obj.value = obj.value.replace(/\-{2,}/g,"-"); //只保留第一个, 清除多余的obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数}