Monday 11 March 2013


Javascript code for phone number format in mscrm 2011:by srinivas kalwakuntla


//Phone Number Format
function FormatPhoneNumber(context) {
    var oField = context.getEventSource().getValue();
    var sTmp = oField;

    if (typeof (oField) != "undefined" && oField != null) {
        sTmp = oField.replace(/[^0-9]/g, "");
        switch (sTmp.length) {
            case 10:
                sTmp = sTmp.substr(0, 3) + "-" + sTmp.substr(3, 3) + "-" + sTmp.substr(6, 4);
                break;


            default:
                alert("Phone Number must contain 10 numbers.");
                break;
        }
    }
    context.getEventSource().setValue(sTmp);
}


No comments:

Post a Comment