From 72a38c012ad237a9cf5b3ced09e7a129188c5e2b Mon Sep 17 00:00:00 2001 From: Bryan Mauger Date: Tue, 27 Jun 2023 13:55:42 -0400 Subject: [PATCH] CSR-1479 fix regex that prevents using number "1" as the... first number in telephone number. --- .../phonenumber-question/phonenumber-question.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/digital-components/phonenumber-question/phonenumber-question.vue b/src/digital-components/phonenumber-question/phonenumber-question.vue index ff0bbadd9..7f2525bcb 100644 --- a/src/digital-components/phonenumber-question/phonenumber-question.vue +++ b/src/digital-components/phonenumber-question/phonenumber-question.vue @@ -75,8 +75,13 @@ export default { // Update the phone number with the formatted version return formattedNumber; }, - filterNumber() { - this.selectedValue = this.selectedValue.replace(/1/g, ""); + filterNumber(event) { + const regex = /^(?!1)\d+/; + const inputValue = event.target.value; + if (!regex.test(inputValue)) { + // If the input violates the regex pattern, remove the leading 1 + event.target.value = inputValue.replace(/^1/, ""); + } }, }, watch: {