From 1166d3499f2e3d23d8e14eeaab8a6e9f5d9d8f76 Mon Sep 17 00:00:00 2001 From: Lan Hui <1348141770@qq.com> Date: Thu, 5 Sep 2024 10:11:20 +0800 Subject: [PATCH] Fix bug 478 --- app/templates/signup.html | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/templates/signup.html b/app/templates/signup.html index 975c1fb..6ff0445 100644 --- a/app/templates/signup.html +++ b/app/templates/signup.html @@ -21,6 +21,27 @@ slider.init(); // 初始化滑块解锁功能 }); + function containsDigitsLettersSpecialCharacters(s) { + let resultD = 0, resultL = 0, resultS = 0; + + // Digit test + '0123456789'.split('').forEach((x) => { + if (s.includes(x)) + resultD = 1; + }); + + // Letter test + resultL = /[a-z]/i.test(s); + + // Special charater test + '+-*/,.:;/\[]<>$%&()!?^~'.split('').forEach((x) => { + if (s.includes(x)) + resultS = 1; + }); + + return resultD + resultL + resultS == 3; + } + function signup(){ // 发起 AJAX 请求来处理注册 username = $("#username").val().trim(); @@ -44,6 +65,10 @@ alert('密码过于简单。(密码长度至少4位)'); return false; } + if (!containsDigitsLettersSpecialCharacters(password)) { + alert('密码过于简单。(密码要包括数字,字母,特殊符号)'); + return false; + } is_ok = slider.getIsOk(); if(!is_ok){ alert('没有滑动验证'); -- 2.17.1