Merge pull request #1529 from Safelite/feature/CSR-1393.1

validate alphanumeric values
This commit is contained in:
AMSNEHA 2023-11-15 18:20:12 +05:30 committed by GitHub
commit 2e159ef37f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View file

@ -217,13 +217,11 @@ export default {
} else { } else {
if (promoCodeData.errorCode == promoErrorCodes.PROMO_STACKING_NOT_ALLOWED) { if (promoCodeData.errorCode == promoErrorCodes.PROMO_STACKING_NOT_ALLOWED) {
this.displayInvalidOnOrderPromoAlert = true; this.displayInvalidOnOrderPromoAlert = true;
this.focusOnPromoInput();
this.resetModalButtonStyle();
} else { } else {
this.displayInvalidPromoAlert = true; this.displayInvalidPromoAlert = true;
this.focusOnPromoInput();
this.resetModalButtonStyle();
} }
this.focusOnPromoInput();
this.resetModalButtonStyle();
} }
} }
}, },

View file

@ -8,6 +8,7 @@
cornerStyle="rounded" cornerStyle="rounded"
:displayQuestionText="false" :displayQuestionText="false"
isRequired isRequired
@input="validateAlphanumeric"
validationRules="promo-required" /> validationRules="promo-required" />
</template> </template>
@ -22,6 +23,8 @@ import { errorMessages } from "@/constants/error-messages";
// Define Validation Rules // Define Validation Rules
defineRule("promo-required", required(errorMessages.PROMO_REQUIRED)); defineRule("promo-required", required(errorMessages.PROMO_REQUIRED));
const ALPHANUMERIC_REGEX = /[^a-zA-Z0-9]/g;
export default { export default {
name: "promo-question", name: "promo-question",
props: { props: {
@ -38,6 +41,11 @@ export default {
}, },
}, },
}, },
methods: {
validateAlphanumeric() {
this.value = this.value.replace(ALPHANUMERIC_REGEX, "");
},
},
components: { components: {
textboxQuestion, textboxQuestion,
}, },