From 7697d180025c68e0bc55896f72573c767bafc199 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9C=A7=E9=9B=A8=E3=83=90=E3=83=8B=E3=83=A9=E3=83=BC?= <118162831+kirisamevanilla@users.noreply.github.com> Date: Thu, 18 Jun 2026 21:51:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E6=97=B6=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E7=AE=80=E6=98=93=E6=A0=A1=E9=AA=8Cusername?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/ForginsterPage.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pages/ForginsterPage.tsx b/src/pages/ForginsterPage.tsx index e74bfb7..7b366b4 100644 --- a/src/pages/ForginsterPage.tsx +++ b/src/pages/ForginsterPage.tsx @@ -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; @@ -342,6 +347,8 @@ function RegisterTab() { type="text" name="username" placeholder={loc('EnterUsername', '输入用户名')} + pattern="[a-zA-Z0-9]+" + title={loc('InvalidUsernameFormat', '用户名只能包含字母和数字')} required />