diff --git a/app/templates/login.html b/app/templates/login.html index b8eb118..169c669 100644 --- a/app/templates/login.html +++ b/app/templates/login.html @@ -15,6 +15,11 @@ alert('输入不能为空!'); return false; } + let reg = /^\S*$/; // 正则表达式,用于匹配不包含空格的字符串 + if (!reg.test(password)) { + alert('输入不能包含空格!'); + return false; + } $.post( "/login", {'username': username, 'password': password}, function (response) { diff --git a/app/templates/reset.html b/app/templates/reset.html index 3425c97..4834695 100644 --- a/app/templates/reset.html +++ b/app/templates/reset.html @@ -12,6 +12,11 @@ alert('输入不能为空!'); return false; } + let reg = /^\S*$/; // 正则表达式,用于匹配不包含空格的字符串 + if (!reg.test(old_password) || !reg.test(new_password)) { + alert('输入不能包含空格!'); + return false; + } if (new_password !== re_new_password) { alert('新密码不匹配,请重新输入'); return false; diff --git a/app/templates/signup.html b/app/templates/signup.html index 5b3aafe..8d688f3 100644 --- a/app/templates/signup.html +++ b/app/templates/signup.html @@ -16,6 +16,11 @@ You're logged in already! Logout. alert('输入不能为空!'); return false; } + let reg = /^\S*$/; // 正则表达式,用于匹配不包含空格的字符串 + if (!reg.test(password) || !reg.test(password2)) { + alert('输入不能包含空格!'); + return false; + } if (password !== password2) { alert('确认密码与输入密码不一致!'); return false;