iview 自定義驗證

// 自定義驗證,重複密碼是否與第一次輸入的密碼一致
            const validatePass = (rule, value, callback) => {
                // console.log(rule)
                // console.log(value)
                if (value === '' || value !== this.formValidate.password) {
                    callback(new Error('兩次輸入不一致'));
                } else {
                    callback();
                }
            };
ruleValidate: {
 re_password: [
                { required: true, message: '請輸入密碼', trigger: 'blur' },
                { type: 'string', min: 8, message: '密碼不能小於八位數', trigger: 'blur' },
                { validator: validatePass, trigger: 'blur' }
              ]

}

https://github.com/yiminghe/async-validator#async-validatorjavascript

相關文章
相關標籤/搜索