Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/pages/ForginsterPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ function RegisterTab() {
event.preventDefault();

const formData = new FormData(event.currentTarget);
const username = formData.get('username') as string;
if (!/^[a-zA-Z0-9]+$/.test(username)) {
toast.error(loc('InvalidUsernameFormat', '用户名只能包含字母和数字'));
return;
}
if (formData.get('password') !== formData.get('password2')) {
toast.error(loc('PasswdNoMatch', '两次密码不匹配'));
return;
Expand Down Expand Up @@ -342,6 +347,8 @@ function RegisterTab() {
type="text"
name="username"
placeholder={loc('EnterUsername', '输入用户名')}
pattern="[a-zA-Z0-9]+"
title={loc('InvalidUsernameFormat', '用户名只能包含字母和数字')}
required
/>
</div>
Expand Down