This is an automated email from the ASF dual-hosted git repository. shuai pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit d886b1b7cacda1d509f1a132dda2fe70ec8afc4a Author: hgaol <[email protected]> AuthorDate: Wed Jun 12 23:07:27 2024 +0800 fix: incomplete display of error message alerts on registration page --- .../Users/Register/components/SignUpForm/index.tsx | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/ui/src/pages/Users/Register/components/SignUpForm/index.tsx b/ui/src/pages/Users/Register/components/SignUpForm/index.tsx index bfa5d23e..ba9d4fb8 100644 --- a/ui/src/pages/Users/Register/components/SignUpForm/index.tsx +++ b/ui/src/pages/Users/Register/components/SignUpForm/index.tsx @@ -55,6 +55,7 @@ const Index: React.FC<Props> = ({ callback }) => { const updateUser = userStore((state) => state.update); const emailCaptcha = useCaptchaPlugin('email'); + const nameRegex = /^[\w.-\s]{4,30}$/; const handleChange = (params: FormDataType) => { setFormData({ ...formData, ...params }); @@ -62,7 +63,30 @@ const Index: React.FC<Props> = ({ callback }) => { const checkValidated = (): boolean => { let bol = true; - const { e_mail, pass } = formData; + const { name, e_mail, pass } = formData; + + if (!name.value) { + bol = false; + formData.name = { + value: '', + isInvalid: true, + errorMsg: t('name.msg.empty'), + }; + } else if (name.value.length > 30) { + bol = false; + formData.name = { + value: '', + isInvalid: true, + errorMsg: t('name.msg.range'), + }; + } else if (!nameRegex.test(name.value.length)) { + bol = false; + formData.name = { + value: '', + isInvalid: true, + errorMsg: t('name.msg.character'), + }; + } if (!e_mail.value) { bol = false;
