From 61aeb06e0ab4babd816716d4d72ae4a9ca8e4069 Mon Sep 17 00:00:00 2001 From: Sneha Date: Wed, 15 Nov 2023 16:02:21 +0530 Subject: [PATCH 1/2] validate alphanumeric values --- .../promo-modal-question/promo-question/promo-question.vue | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/layouts/payment-method/promo-modal-question/promo-question/promo-question.vue b/src/layouts/payment-method/promo-modal-question/promo-question/promo-question.vue index 25744e652..7b4fd9049 100644 --- a/src/layouts/payment-method/promo-modal-question/promo-question/promo-question.vue +++ b/src/layouts/payment-method/promo-modal-question/promo-question/promo-question.vue @@ -8,6 +8,7 @@ cornerStyle="rounded" :displayQuestionText="false" isRequired + @input="validateAlphanumeric" validationRules="promo-required" /> @@ -38,6 +39,11 @@ export default { }, }, }, + methods: { + validateAlphanumeric() { + this.value = this.value.replace(/[^a-zA-Z0-9]/g, ""); + }, + }, components: { textboxQuestion, }, From bc3468f8d62ca2f277b8a7d9255e8d29494da2b7 Mon Sep 17 00:00:00 2001 From: Sneha Date: Wed, 15 Nov 2023 18:14:52 +0530 Subject: [PATCH 2/2] Format --- .../promo-modal-question/promo-modal-question.vue | 6 ++---- .../promo-modal-question/promo-question/promo-question.vue | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue b/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue index ac42fce2e..deff594e5 100644 --- a/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue +++ b/src/layouts/payment-method/promo-modal-question/promo-modal-question.vue @@ -217,13 +217,11 @@ export default { } else { if (promoCodeData.errorCode == promoErrorCodes.PROMO_STACKING_NOT_ALLOWED) { this.displayInvalidOnOrderPromoAlert = true; - this.focusOnPromoInput(); - this.resetModalButtonStyle(); } else { this.displayInvalidPromoAlert = true; - this.focusOnPromoInput(); - this.resetModalButtonStyle(); } + this.focusOnPromoInput(); + this.resetModalButtonStyle(); } } }, diff --git a/src/layouts/payment-method/promo-modal-question/promo-question/promo-question.vue b/src/layouts/payment-method/promo-modal-question/promo-question/promo-question.vue index 7b4fd9049..053e8eedc 100644 --- a/src/layouts/payment-method/promo-modal-question/promo-question/promo-question.vue +++ b/src/layouts/payment-method/promo-modal-question/promo-question/promo-question.vue @@ -23,6 +23,8 @@ import { errorMessages } from "@/constants/error-messages"; // Define Validation Rules defineRule("promo-required", required(errorMessages.PROMO_REQUIRED)); +const ALPHANUMERIC_REGEX = /[^a-zA-Z0-9]/g; + export default { name: "promo-question", props: { @@ -41,7 +43,7 @@ export default { }, methods: { validateAlphanumeric() { - this.value = this.value.replace(/[^a-zA-Z0-9]/g, ""); + this.value = this.value.replace(ALPHANUMERIC_REGEX, ""); }, }, components: {