Thursday, August 8, 2019

How to validate mobile number in Dynamic CRM

More Reference here

How to format a phone number in Dynamic 365 crm

How to validate mobile with country code in Dynamic CRM

How to validate mobile number in Dynamic CRM

Remove comma from number fields in Dynamic 365 CRM




Below is a JavaScript code to validate mobile number in Dynamic CRM

vjCity.ValidateMobileNumber = function (mobileNumber, fieldname)

{
 var re = /^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,12}$/im;
 if (!re.test(mobileNumber))
 {
    if (Xrm.Page.context.getUserLcid() == 1025)
        vjCity.showFieldNotificiation(fieldname, "تعريف الرقم خطأ");
    else
        vjCity.showFieldNotificiation(fieldname, "Invalid number format");
 }
 else
 {
    vjCity.clearFieldNotification(fieldname);
 }
}


vjCity.showFieldNotificiation = function (fieldname, message) 
{
    Xrm.Page.getControl(fieldname).setNotification(message);
};

vjCity.clearFieldNotification = function (fieldname) 
{
    Xrm.Page.getControl(fieldname).clearNotification();
};

vjCity.showFormNotification = function (message, type, number) 
{
    Xrm.Page.ui.setFormNotification(message, type, number);
};

vjCity.clearFormNotification = function (number) 
{
    Xrm.Page.ui.clearFormNotification(number);
};

No comments: