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