如何在Dynamic crm 2013中应用遮罩 [英] How to apply masking in Dynamic crm 2013

查看:91
本文介绍了如何在Dynamic crm 2013中应用遮罩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有某种方法可以使用任何jQuery和jQuery掩码插件在表单上的crm 2013中的字段上应用掩码。

Is there is some way to apply mask on fields in crm 2013 on forms, using any jQuery and jQuery mask plugins.

我从 http://taoofcrm.com/2011/05/19/crm-field-masking -with-jquery /
,但不适用于Dynamic crm 2013。

I read from http://taoofcrm.com/2011/05/19/crm-field-masking-with-jquery/ but it not worked for me on Dynamic crm 2013.

推荐答案

在crm 2011输入字段ID是属性的名称,而在crm 2013输入字段ID是属性的名称加上 _i(可以是 i表示输入)。

In crm 2011 input field ID is the name of attribute, while in crm 2013 input field ID is the name of attribute plus "_i" (may be "i" denote an input).

因此,如果我们有属性名称 name,则此属性的输入字段ID在2011年为 name,在2013年为 name_i。

So if we have attribute name "name" then input field ID for this attribute in 2011 is "name" and in 2013 it is "name_i".

以下是crm 2011和crm 2013中表单上属性输入字段的源视图。

Following is the Source view of input field of an attribute on the form in crm 2011 and crm 2013.

crm 2011中的输入字段

 <input id="name" tabindex="1010" class="ms-crm-Input ms-crm-Text" style="-ms-ime-mode: auto;" type="text" maxlength="255" value="test" attrformat="text" attrpriv="7" attrname="name" req="2">

crm 2013中的输入字段

<input id="name_i" title="" class="ms-crm-InlineInput" aria-labelledby="name_c name_w" style="-ms-ime-mode: active;" type="text" maxlength="160" attrname="name" attrpriv="7" controlmode="normal" defaultvalue="Blue Yonder Airlines (sample)">

如果您在crm 2011中应用屏蔽,请参阅此处!,或仅使用以下代码。

If you applying masking in crm 2011, then please see here!, or just use following code.

//Include jquery and jqueryMask plugin file on form you apply masking.
function Mask(field, format)
{ 
$("#"+field).mask(format);
}

// call this function on form load event 
function maskFields()
{
Mask("address1_postalcode", "99999-9999");
Mask("telephone1", "(999) 999-9999");
Mask("telephone2", "(999) 999-9999");
Mask("fax", "(999) 999-9999");

}

对于crm 2013 ,您应该

function Mask(field, format)
{ 
$("#"+field+"_i").mask(format);
}

但仍然无法正常工作,因为在crm 2013中,输入字段是在执行时创建的。
您应该在输入的单击事件上应用遮罩,在应用遮罩之前刚刚获得属性的焦点,例如

But also still not working because in crm 2013 input fields are created on execution time. you should apply masking on click event of input, or just got focus of attribute before apply masking e.g.

//Include jquery and jqueryMask plugin file on form you apply masking.
function Mask(field, format) {
  //first check whether attribute exist or not
    var oCtrl = Xrm.Page.getControl(field);
    if (oCtrl != null) {

        oCtrl.setFocus(true);
        $("#" + field + "_i").mask(format);
    }
} 

// call this function on form load event 
function maskFields()
{
Mask("address1_postalcode", "99999-9999");
Mask("telephone1", "(999) 999-9999");
Mask("telephone2", "(999) 999-9999");
Mask("fax", "(999) 999-9999");

}

在crm 2013上运行良好。

Worked well for crm 2013.

这篇关于如何在Dynamic crm 2013中应用遮罩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆