1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-04-06 03:57:53 +08:00

可以使用正则表达式来验证密码是否至少包含一个大写字母和一个小写字母

This commit is contained in:
万洺岐 2024-11-04 22:02:01 +08:00
parent 9ca8a2a9b7
commit c78606c6f7

View File

@ -88,13 +88,16 @@ export default {
callback() callback()
} }
} }
// 使
const validatePassword = (rule, value, callback) => { const validatePassword = (rule, value, callback) => {
if (value.length < 6) { if (value.length < 6) {
callback(new Error('The password can not be less than 6 digits')) callback(new Error('The password can not be less than 6 digits'));
} else { } else if (!/[a-z]/.test(value) ||!/[A-Z]/.test(value)) {
callback() callback(new Error('The password should contain both uppercase and lowercase letters'));
} } else {
callback();
} }
};
return { return {
loginForm: { loginForm: {
username: 'admin', username: 'admin',