<el-form-item
label="打款金额:"
prop="age">
<el-input type="age" v-model="numberValidateForm.age" autocomplete="off"></el-input>
</el-form-item>
data:
age: [
{required: true, type: 'string', trigger: 'blur', message: '打款金额不能为空'},
{
pattern: /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
message: '请输入正确额格式,可保留两位小数'
}
]
效果:
![image.png](https://upload-images.jianshu.io/upload_images/21024145-5fdfeeb8de34299c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
输入金额判定
let rp = /(?:[1-9]([0-9]+)?(?:.[0-9]{1,2})?$)|(?:^(?:0)$)|(?:[0-9].0-9?message.error("请输入正确金额");
return
}```
let priceReg = /(?:[1-9]([0-9]+)?(?:.[0-9]{1,2})?$)|(?:^(?:0)$)|(?:[0-9].0-9?message.error("请输入正确金额");
return false;
}