vue input浮点数正则校验,允许输入0.0几
obj[val] = obj[val].replace(/^\D*([1-9]\d*\.?\d{0,3})?.*$/,'$1');想要小数点后几位就把这个数字改为几@keyup.native="checkNumber('expenseBillAmount',scope.row)" @blur="checkNumberAgain('expenseBillAmount',scop...
·
obj[val] = obj[val].replace(/^\D*([1-9]\d*\.?\d{0,3})?.*$/,'$1');
想要小数点后几位就把这个数字改为几
@keyup.native="checkNumber('expenseBillAmount',scope.row)" @blur="checkNumberAgain('expenseBillAmount',scope.row)"
checkNumber(val,obj) {
obj[val] = obj[val].replace(/^\D*([0-9]\d*\.?\d{0,3})?.*$/,'$1');
},
checkNumberAgain(val,obj){
if(obj[val]){
if(Number(obj[val]) === 0){
this.$message({
message: "非法数值",
type: "warning"
});
obj[val] = null;
return ;
}
obj[val] = obj[val].replace(/^\D*([0-9]\d*\.?\d{0,3})?.*$/,'$1');
}
},
更多推荐
已为社区贡献1条内容
所有评论(0)