const validatePass2 = (rule: any, value: any, callback: any) => {
const regex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]+$/;
if (!value) {
return callback(new Error("请输入密码"));
} else if (!regex.test(value)) {
return callback(new Error("密码必须由字母和数字组成"));
} else {
callback();
}
};
const validateAckPassword = (rule, value, callback) => {
if (resetPassword.form.password == "") return callback();
if (value !== resetPassword.form.password) {
return callback(new Error("两次输入的密码不一致"));
} else {
callback();
}
};
const validateAckPassword2 = (rule, value, callback) => {
if (resetPassword.form.ackNewPassword == "") return callback();
if (value !== resetPassword.form.ackNewPassword) {
return callback(new Error("两次输入的密码不一致"));
} else {
callback();
}
};
const resetPassword = reactive({
dialogVisible: false,
form: {
oldPassword: "",
password: "",
ackNewPassword: "",
},
rules: {
oldPassword: [{ required: true, message: "请输入旧密码", trigger: "blur" }],
password: [
{ required: true, message: "请输入新密码", trigger: "blur" },
{ validator: validatePass2, trigger: "blur" },
],
ackNewPassword: [
{ required: true, message: "请输入新密码", trigger: "blur" },
{ validator: validateAckPassword, trigger: "blur" },
],
},
});
密码验证校验
最新推荐文章于 2024-09-01 15:30:33 发布