上传文件至 app/templates

pull/134/head
钱乐涛 2024-06-02 20:54:38 +08:00
parent d8af2a7e54
commit 7181db9510
3 changed files with 25 additions and 19 deletions

View File

@ -11,12 +11,14 @@
function login(){
let username = $("#username").val();
let password = $("#password").val();
let regex = /^[a-zA-Z0-9_]*$/;
if (username === "" || password === ""){
alert('输入不能为空!');
return false;
}
if (password.includes(' ')) {
alert('输入不能包含空格!');
if (!regex.test(username) || !regex.test(password)) {
alert('用户名和密码只能包含英文字母和数字!');
return false;
}
$.post(
@ -29,7 +31,7 @@
window.location.href = "/"+username+"/userpage";
}
}
)
);
return false;
}
</script>
@ -46,5 +48,4 @@
</div>
{% endif %}
{% endblock %}
{% endblock %}

View File

@ -8,14 +8,12 @@
let old_password = $("#old-password").val();
let new_password = $("#new-password").val();
let re_new_password = $("#re-new-password").val();
let regex = /^[a-zA-Z0-9_]*$/;
if (old_password === "" || new_password === "" || re_new_password === ""){
alert('输入不能为空!');
return false;
}
if (old_password.includes(' ') || new_password.includes(' ')) {
alert('输入不能包含空格!');
return false;
}
if (new_password !== re_new_password) {
alert('新密码不匹配,请重新输入');
return false;
@ -24,6 +22,11 @@
alert('密码过于简单。(密码长度至少4位)');
return false;
}
if (!regex.test(new_password)) {
alert('新密码只能包含英文字母和数字!');
return false;
}
$.post("/reset", {'old-password': old_password, 'new-password': new_password},
function (response) {
if (response.status === '1') {
@ -34,7 +37,7 @@
window.location.href = "/reset";
}
}
)
);
return false;
}
</script>

View File

@ -12,14 +12,12 @@ You're logged in already! <a href="/logout">Logout</a>.
let username = $("#username").val();
let password = $("#password").val();
let password2 = $("#password2").val();
let regex = /^[a-zA-Z0-9_]*$/;
if (username === "" || password === "" || password2 === ""){
alert('输入不能为空!');
return false;
}
if (password.includes(' ') || password2.includes(' ')) {
alert('输入不能包含空格!');
return false;
}
if (password !== password2) {
alert('确认密码与输入密码不一致!');
return false;
@ -28,6 +26,11 @@ You're logged in already! <a href="/logout">Logout</a>.
alert('密码过于简单。(密码长度至少4位)');
return false;
}
if (!regex.test(username) || !regex.test(password)) {
alert('用户名和密码只能包含英文字母和数字!');
return false;
}
$.post("/signup", {'username': username, 'password': password},
function (response) {
if (response.status === '0') {
@ -47,7 +50,7 @@ You're logged in already! <a href="/logout">Logout</a>.
alert(response.warn);
}
}
)
);
return false;
}
</script>
@ -60,13 +63,12 @@ You're logged in already! <a href="/logout">Logout</a>.
<h1>Sign up</h1>
</section>
<p><input type="username" id="username" placeholder="输入用户名" class="username"></p>
<p><input type="text" id="username" placeholder="输入用户名" class="username"></p>
<p><input type="password" id="password" placeholder="输入密码" class="password"></p>
<p><input type="password" id="password2" placeholder="确认密码" class="password" ></p>
<button type="button" class="btn" onclick="signup()">注册</button>
</div>
{% endif %}
{% endblock %}
{% endif %}
{% endblock %}