2013-12-18 45 views
0

我想更改文本字段的标签。 它应该以黑色显示电子邮件,然后显示红色星号。 页面的代码是这一个:在CRM 2011中使用JS更改字段的标签颜色

<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?

+1

您可以添加JavaScript,它触发表单的onload并执行这些操作。然而,不通过API完成的任何操作(如您建议的操作)都不受支持,并且可能随时将汇总或新版本应用于您的CRM环境。 –

回答

0

您可以使用jQuery这一点,但它是不支持的,而不是在所有好主意(过去的经验!)

如果你需要有一个功能,它不仅仅是一个领域,可能更最好构建一个HTML Web资源。

尼克

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"); 
} 
+0

该字段是复选框,因此无法根据需要进行设置,因为它从不真正存储任何值。 – MaPi