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 {
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();
}
}
},

View file

@ -8,6 +8,7 @@
cornerStyle="rounded"
:displayQuestionText="false"
isRequired
@input="validateAlphanumeric"
validationRules="promo-required" />
</template>
@ -22,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: {
@ -38,6 +41,11 @@ export default {
},
},
},
methods: {
validateAlphanumeric() {
this.value = this.value.replace(ALPHANUMERIC_REGEX, "");
},
},
components: {
textboxQuestion,
},