vue form 验证

vue 验证
<Form :model="formModel" label-position="center" :label-width="90" ref="modelForm" :rules="rules">
rules: {
inspectCycleValue: [
{ validator: validateInterval, trigger: "blur" }
],}
const validateInterval = (rule, value, callback) => {
if(this.formModel.cycleValue == "其他"){
if (value === "") {
callback(new Error("请填写巡检周期"));
} else if (!/^[0-9]*$/.test(value)) {
callback(new Error("只能输入整数"));
} else if (value.charAt(0) == 0) {
callback(new Error("不能以‘0’开头"));
}else {
callback();
}
}else {
callback();
}
};

posted @ 2019-05-23 19:48  A影子放風箏  阅读(253)  评论(0编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css