RE: Phone number validate
Hi,
You can create or use a PCF. See pcf.gallery/.../ for example. A regular expression like \(\d{3}\) \d{3}-\d{4};ext=\d{2} should works.
Or you can write a javascript code that check the format with a regex:
const invalidPhoneNumberNotif = "INVALID_PHONE_NUMBER_FORMAT";
function checkPhoneNumberFormat(execCtx) {
const formCtx = execCtx.getFormContext();
const phoneNumberAttr = execCtx.getEventSource();
const phoneNumberCtrl = formCtx.getControl(phoneNumberAttr.getName());
const phoneNumber = phoneNumberAttr.getValue();
const phoneNumberRegex = /\(\d{3}\) \d{3}-\d{4};ext=\d{2}/;
if (phoneNumber != null && !phoneNumberRegex.test(phoneNumber)) {
phoneNumberCtrl.setNotification("Phone number format must be (123) 456-7890;ext=12", invalidPhoneNumberNotif);
}
else {
phoneNumberCtrl.clearNotification(invalidPhoneNumberNotif);
}
}
Add this javascript function to the "on change" event of your phone number fields. Ensure to check "Pass the execution context as first parameter".
If ;ext=12 is optional, you will need to adapt the regex. You can test/adapt the regex here: regex101.com/.../1