From 9c33e77755500a8a669e36aae487fdd5849b9e76 Mon Sep 17 00:00:00 2001 From: Piyush Gupta <56182734+gupta-piyush19@users.noreply.github.com> Date: Fri, 7 Feb 2025 09:59:30 +0530 Subject: [PATCH] fix: phone number validations (#4708) Co-authored-by: Dhruwang Jariwala <67850763+Dhruwang@users.noreply.github.com> --- .../src/components/questions/open-text-question.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/surveys/src/components/questions/open-text-question.tsx b/packages/surveys/src/components/questions/open-text-question.tsx index 592e2a737a..9a3e690662 100644 --- a/packages/surveys/src/components/questions/open-text-question.tsx +++ b/packages/surveys/src/components/questions/open-text-question.tsx @@ -111,10 +111,16 @@ export function OpenTextQuestion({ handleInputChange(e.currentTarget.value); }} className="fb-border-border placeholder:fb-text-placeholder fb-text-subheading focus:fb-border-brand fb-bg-input-bg fb-rounded-custom fb-block fb-w-full fb-border fb-p-2 fb-shadow-sm focus:fb-outline-none focus:fb-ring-0 sm:fb-text-sm" - pattern={question.inputType === "phone" ? "[0-9+ ]+" : ".*"} + pattern={question.inputType === "phone" ? "^[0-9+][0-9+\\- ]*[0-9]$" : ".*"} title={question.inputType === "phone" ? "Enter a valid phone number" : undefined} minlength={question.inputType === "text" ? question.charLimit?.min : undefined} - maxlength={question.inputType === "text" ? question.charLimit?.max : undefined} + maxlength={ + question.inputType === "text" + ? question.charLimit?.max + : question.inputType === "phone" + ? 30 + : undefined + } /> ) : (