valid

作者: Eden0204 | 来源:发表于2018-12-27 11:47 被阅读0次
    const _ = this;
                const empty = (rule, value, callback) => {
                    if (!value || value[0] === "") {
                        return callback(new Error('必填项'));
                    } else {
                        callback();
                    }
                };
                const emptyT1 = (rule, value, callback) => {
                    if (this.formItem.st1 === "" || this.formItem.t1 === "") {
                        return callback(new Error('必填项'));
                    } else {
                        callback();
                    }
                };
                const emptyT2 = (rule, value, callback) => {
                    if (this.formItem.st2 === "" || this.formItem.t2 === "") {
                        return callback(new Error('必填项'));
                    } else {
                        callback();
                    }
                };
                const emptyRoom = (rule, value, callback) => {
                    if (_.formValidate.single_room === "" || _.formValidate.double_room === "") {
                        return callback(new Error('房间数量都不可为空,且取值为0~999'));
                    } else {
                        callback();
                    }
                };
                const emptyCompany = (rule, value, callback) => {
                    if (!value || value[0] === "") {
                        return callback(new Error('请选择一家公司'));
                    } else {
                        callback();
                    }
                };
                const phone = (rule, value, callback) => {
                    if (!/^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/.test(value)) {
                        callback(new Error('请输入正确的手机号'));
                    } else {
                        callback();
                    }
                };
                const email = (rule, value, callback) => {
                    if (!/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/.test(value)) {
                        callback(new Error('请输入合法的邮箱'));
                    } else {
                        callback();
                    }
                };
    
    address: [
                            {validator: empty, trigger: 'blur'},
                            {type: 'string', max: 30, message: '不能超过30个字符', trigger: 'blur'}
                        ],
                        time: [
                            {validator: empty, trigger: 'change'}
                        ],
    

    相关文章

      网友评论

        本文标题:valid

        本文链接:https://www.haomeiwen.com/subject/cglrlqtx.html