الجمعة، 13 سبتمبر 2013

CRM 2011:Set First Characters of String To UpperCase

function SetCapitalLetters(ControlName) { 
    Xrm.Page.getAttribute(ControlName).addOnChange(function () {
    var newVal = '';  
        var CtrVal = Xrm.Page.getAttribute(ControlName).getValue();
        var CtrValues = CtrVal.split(" ");
        for (var i = 0; i < CtrValues.length; i++) {
            if (newVal == '')
                newVal = CtrValues[i].substr(0, 1).toUpperCase() + CtrValues[i].substr(1, CtrValues[i].length).toLowerCase();
            else
                newVal += ' ' + CtrValues[i].substr(0, 1).toUpperCase() + CtrValues[i].substr(1, CtrValues[i].length).toLowerCase();
        }
        SetValueAttribute(ControlName,newVal);
    });
}

ليست هناك تعليقات:

إرسال تعليق