shit element ui & form password validation
shit element ui & form password validation
shit docs
https://github.com/yiminghe/async-validator#validate
https://element.eleme.io/#/zh-CN/component/form#biao-dan-yan-zheng
passWord: [
{
required: true,
message: "请输入密码",
trigger: "blur",
},
{
min: 3,
max: 20,
message: "长度在 3 到 20 个字符",
trigger: "blur",
}
],
passWordSure: [
{
required: true,
message: "请输入确认密码",
trigger: "blur",
},
{
min: 3,
max: 20,
// pattern: `^${this.$data.form.passWord}$`,
// pattern: `${this.$data.form.passWordSure}`,
message: "两次输入的密码不一致",
// message: " ",
trigger: "blur",
validator: (rule, value, callback) => {
console.log(`value =`, value);
// console.log(`rule =`, rule);
// console.log(`callback =`, callback);
let pwd = this.$data.form.passWord;
console.log(`passWord =`, pwd);
if(pwd === value) {
// green border
callback();
} else {
// red border
callback(new Error("两次输入的密码不一致"));
// this.$refs.formRef.validateField("passWordSure");
}
},
},
],
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/10039711.html
未经授权禁止转载,违者必究!