Masking & Validation
In order to obtain accurate data through the forms above the page, jquery-validation library is used for validation and inputmask library is used for masking.
Masking (inputmask)
Masking in the checkout page matches the description in the library documentation.
Masking is used for card number only. For Amex or normal credit card, we deviate from standard and conduct controls.
Standard use:
// It should be used inside the constructor() method. this.$cardCVVMasked = new InputMask({ mask: '999' }).mask(this.$cardCVVInput[0]);
We limited CVC number with three digits and applied masking. Using the this.$cardCVVMasked description, we can easily conduct operations such as destory and update in the file by accessing instance.
For credit card:
// It should be used inside the constructor() method. this.$cardInputMasked = new InputMask({ mask: this.getCardNumberMask() }).mask(this.$cardInput[0]);
We applied getCardNumberMask method to mask card number. Using the this.$cardInputMasked description, we can easily conduct operations such as destory and update in the file by accessing instance.
getCardNumberMask = () =>
getValue(selectCardType)?.slug === 'american-express' ?
// if the card type is amex
'9999 999999 99999' :
// if not amex
'9999 9999 9999 9999';American Express (Amex) card numbers consist of 15 digits, while normal credit card numbers consist of 16 digits. Furthermore, while digit grouping format is 4+4+4+4 for normal credit cards, it is4+6+5 for Amex.
Disable masking:
To disable masking, launch method
destroyofinstance. This action should be applied to variables defined when creatingInstances.
Validation (jquery-validation)
Validate Method Documentation: https://jqueryvalidation.org/validate/
Validation in the checkout page matches the description in the library documentation.
Usage example:
Using the this.validator description, we can easily conduct operations such as destory and update in the file by accessing instance.
Disable validation:
To disable validation, launch method
destroyofinstance. This action should be applied on the variable defined when creatingInstances.
Last updated
Was this helpful?

