Working with REGEX for format checking;

We can get the regex as per our need from the google or AI. we can assign the condition and functionality according to our need. For example

Syntax:

let creditCard = paymentRec.getValue({

                        fieldId: ‘custrecord_jj_credit_card’

                    });

                    let regex = /^[0-9]{13,20}$/;

                    if (!regex.test(creditCard)) {

                        alert(‘Credit card numbers must contain between 13 and 20 digits.’);

                        if (creditCard.length < 13) {

                            alert(‘Credit card number must contain between 13 and 20 digits.’);

                        } else if (creditCard.length > 20) {

                            alert(‘Credit card number is not valid. Please check that all digits were entered correctly.’);

                        }

                    }

Leave a comment

Your email address will not be published. Required fields are marked *