data() {
var valiNumberPass1 = (rule, value, callback) => {//包含小数
let reg = /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g;
if (value === '') {
callback(new Error('请输入内容'));
} else if (!reg.test(value)) {
callback(new Error('请输入数字'));
} else {
callback();
}
};
return {
rules: {
zcfy: [
{ validator:valiNumberPass1,required: true, message: '租车费用只能为数字', trigger: 'blur'}
],
lxfs: [
{
required: true,
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: "请输入正确的手机号码",
trigger: "blur"
}
],
sfz:[
{
required: true,
pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
message: "请输入正确的身份证号码",
trigger: "blur"
}
],
},
}
},
vue 表单效验小数以及整数 及手机号身份证号
最新推荐文章于 2024-07-09 17:15:54 发布