From 8b0b916ea5c2a84c59cd9698356d8a2181d93788 Mon Sep 17 00:00:00 2001 From: mohitb35 <44917347+mohitb35@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:24:30 -0500 Subject: [PATCH] feat: updates contact form val. (first/last name) - disallows entries beginning with special characters --- public/static/locales/en/editProfile.json | 4 ++-- src/features/user/CompleteSignup/index.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/static/locales/en/editProfile.json b/public/static/locales/en/editProfile.json index 83daae44b8..aabc9742e2 100644 --- a/public/static/locales/en/editProfile.json +++ b/public/static/locales/en/editProfile.json @@ -41,9 +41,9 @@ "validationErrors": { "maxChars": "Should be {{max}} characters or less", "firstNameRequired": "First Name field is required", - "firstNameInvalid": "First name is invalid. Only these special characters are allowed: space ' . -", + "firstNameInvalid": "First name is invalid. It cannot start with a special character, and only these special characters are allowed: space ' . -", "lastNameRequired": "Last Name field is required", - "lastNameInvalid": "Last name is invalid. Only these special characters are allowed: space ' -", + "lastNameInvalid": "Last name is invalid. It cannot start with a special character, and only these special characters are allowed: space ' -", "emailRequired": "Email is required", "nameRequired": "Please enter a name", "nameInvalid": "Name is invalid. Only these special characters are allowed: space . , ' & ( ) ! -", diff --git a/src/features/user/CompleteSignup/index.tsx b/src/features/user/CompleteSignup/index.tsx index 28ed337303..4d1d6bcbbe 100644 --- a/src/features/user/CompleteSignup/index.tsx +++ b/src/features/user/CompleteSignup/index.tsx @@ -307,7 +307,7 @@ export default function CompleteSignup(): ReactElement | null { message: t('validationErrors.maxChars', { max: 50 }), }, pattern: { - value: /^[\p{L}\p{N}\sß.'-]+$/u, + value: /^[\p{L}\p{N}ß][\p{L}\p{N}\sß.'-]*$/u, message: t('validationErrors.firstNameInvalid'), }, }} @@ -335,7 +335,7 @@ export default function CompleteSignup(): ReactElement | null { message: t('validationErrors.maxChars', { max: 50 }), }, pattern: { - value: /^[\p{L}\p{N}\sß'-]+$/u, + value: /^[\p{L}\p{N}ß][\p{L}\p{N}\sß'-]*$/u, message: t('validationErrors.lastNameInvalid'), }, }}