From 525ccdc238ccd75d305e544aedda6a6622421d25 Mon Sep 17 00:00:00 2001 From: zhwxhhhh <14853330+zhwxhhhh@user.noreply.gitee.com> Date: Thu, 5 Jun 2025 14:07:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B3=A8=E5=86=8C=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E9=99=90=E5=88=B6=EF=BC=8C=E8=A6=81=E6=B1=82=E6=95=B0?= =?UTF-8?q?=E5=AD=97=EF=BC=8C=E5=AD=97=E6=AF=8D=E5=92=8C=E7=89=B9=E6=AE=8A?= =?UTF-8?q?=E5=AD=97=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/js/password.js | 14 ++++++++++++++ app/templates/signup.html | 4 ++++ 2 files changed, 18 insertions(+) create mode 100644 app/static/js/password.js diff --git a/app/static/js/password.js b/app/static/js/password.js new file mode 100644 index 0000000..d768281 --- /dev/null +++ b/app/static/js/password.js @@ -0,0 +1,14 @@ +function containsDigitsLettersSpecialCharacters(s) { + let resultD = 0, resultL = 0, resultS = 0; + + // Digit test + resultD = /\d/.test(s); + + // Letter test + resultL = /[a-zA-Z]/.test(s); + + // Special character test + resultS = /[!@#$%^&*(),.?":{}|<>]/.test(s); + + return resultD + resultL + resultS == 3; +} diff --git a/app/templates/signup.html b/app/templates/signup.html index 9030d41..e1f1f89 100644 --- a/app/templates/signup.html +++ b/app/templates/signup.html @@ -24,6 +24,10 @@ You're logged in already! Logout. alert('密码过于简单。(密码长度至少4位)'); return false; } + if (!containsDigitsLettersSpecialCharacters(password)) { + alert('密码过于简单。(密码要包括数字,字母,特殊符号)'); + return false; + } $.post("/signup", {'username': username, 'password': password}, function (response) { if (response.status === '0') {