Announcements
I need to mask the phone number on an Account Contact card (Quick Create Form), can this be done? If so, how? I have done this on the actual Contact form, just can't seem to find a way to do it on a quick create form.
Please advise, thank you.
Hi, USA80
Do you mean to auto format the mask of the highlighted phone number in the image below?
Here is the code.
function FormatPhoneNo(executionContext) {
try {
var formContext = executionContext.getFormContext();
var nvsField = formContext.getAttribute("telephone1").getValue();
var nvsTmp = nvsField;
if (typeof(nvsField) != "undefined" && nvsField != null) {
nvsTmp = nvsField.replace(/[^0-9]/g, "");
switch (nvsTmp.length) {
case 10:
nvsTmp = "(" nvsTmp.substr(0, 3) ") "
nvsTmp.substr(3, 3) "-" nvsTmp.substr(6, 4);
break;
default:
alert("Phone must contain 10 numeric digits.");
break;
}
}
context.getEventSource().setValue(nvsTmp);
} catch (err) {
alert(err.message);
}
}
Then the Phone Number will be masked as the format: (xxx) xxx-xxxx.
And if a number which has been input does not contain 10 digits, there will be prompt popping up.
You need to modify the code yourself for the specific format.
If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.
Best Regards,
Nya
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156