使用CRM 2011中的JS更改字段的标签颜色

时间:2013-12-18 12:20:38

标签: javascript dynamics-crm-2011

我想更改文本字段的标签。 它应该以黑色显示电子邮件,然后显示红色星号。 页面的代码就是这个:

<td class="ms-crm-FieldLabel-LeftAlign  FormSection_CellPadding ms-crm-Field-Required" id="emailaddress1_c">
    <label for="emailaddress1">
        E-mail
    <img class="ms-crm-ImageStrip-frm_required" alt="Required" src="/_imgs/imagestrips/transparent_spacer.gif?ver=-657574203">
    </label>
</td>

可以在CRM中进行吗?

2 个答案:

答案 0 :(得分:0)

你可以使用jQuery,但它不受支持,根本不是一个好主意(过去的经验!)

如果您需要具备该功能,并且它不仅仅是一个字段,那么最好构建一个HTML Web资源。

尼克

答案 1 :(得分:0)

Crm原生支持制作所需的字段。

您没有指定何时需要该字段。下面的代码演示了两者 在表单加载时以及某些其他属性需要控制需求时,需要填写字段。

var xrmPage = Xrm.Page;
var MyApp = MyApp || {};

/**
     Bind to form onload
*/
function OnCrmPageLoad() {
    /* Create a reference to the attribute that you want to make required */
    MyApp.Attr1 = xrmPage.getAttribute("new_attribute1");
    /* Create another reference to illustrate onchange event */
    MyApp.SomeOtherAttr2 = xrmPage.getAttribute("new_someotherattribute");
    /* Call requireAttribute1 when SomeOtherAttr2 changes */
    MyApp.SomeOtherAttr2.addOnChange(requireAttribute1);
    /* Call requireAttribute1 for the first time when the form loads */
    MyApp.requireAttribute1();
}
/**
    Make the my field required 
*/
MyApp.requireAttribute1 = function () {
    MyApp.Attr1.setRequiredLevel("required");
}