From c78606c6f7387f7eefc1059dd0c8808d27e77cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E6=B4=BA=E5=B2=90?= <3524469622@qq.com> Date: Mon, 4 Nov 2024 22:02:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8=E6=AD=A3?= =?UTF-8?q?=E5=88=99=E8=A1=A8=E8=BE=BE=E5=BC=8F=E6=9D=A5=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E6=98=AF=E5=90=A6=E8=87=B3=E5=B0=91=E5=8C=85?= =?UTF-8?q?=E5=90=AB=E4=B8=80=E4=B8=AA=E5=A4=A7=E5=86=99=E5=AD=97=E6=AF=8D?= =?UTF-8?q?=E5=92=8C=E4=B8=80=E4=B8=AA=E5=B0=8F=E5=86=99=E5=AD=97=E6=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/login/index.vue | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 86246f3c..5640573f 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -88,13 +88,16 @@ export default { callback() } } + // 可以使用正则表达式来验证密码是否至少包含一个大写字母和一个小写字母 const validatePassword = (rule, value, callback) => { - if (value.length < 6) { - callback(new Error('The password can not be less than 6 digits')) - } else { - callback() - } + if (value.length < 6) { + callback(new Error('The password can not be less than 6 digits')); + } else if (!/[a-z]/.test(value) ||!/[A-Z]/.test(value)) { + callback(new Error('The password should contain both uppercase and lowercase letters')); + } else { + callback(); } + }; return { loginForm: { username: 'admin',