CRM Dynamics 2013 JavaScript验证自由文本字段中的最小字符数
我有一个简单的验证,我需要执行的形式,它迫使用户在一个字段中有一个最小数量的字符,我有下面的代码如下,但它不工作,我尝试了加载和保存事件,但没有运气,请协助CRM Dynamics 2013 JavaScript验证自由文本字段中的最小字符数,javascript,dynamics-crm-2013,Javascript,Dynamics Crm 2013,我有一个简单的验证,我需要执行的形式,它迫使用户在一个字段中有一个最小数量的字符,我有下面的代码如下,但它不工作,我尝试了加载和保存事件,但没有运气,请协助 function TemsAndCondtitionsValidation() { var TermsandCon = Xrm.Page.getAttribute("new_termsconditions").getValue(); if(TermsandCon.value.length < 140) { Xrm.Ut
function TemsAndCondtitionsValidation()
{
var TermsandCon = Xrm.Page.getAttribute("new_termsconditions").getValue();
if(TermsandCon.value.length < 140)
{
Xrm.Utility.alertDialog("The length of characters entered are less than the minimum requirement of 140 characters");
}
}
函数temsandConditionsValidation()
{
var TermsandCon=Xrm.Page.getAttribute(“新的条件”).getValue();
如果(术语和con.value.length<140)
{
Xrm.Utility.alertDialog(“输入的字符长度小于140个字符的最低要求”);
}
}
如果新术语条件
是文本类型(单行或多行),您可以简单地如下修复代码:
if(TermsandCon.length < 140)
if(术语长度<140)
使用表单编辑器将此功能附加到onsave事件:
function TemsAndCondtitionsValidation(context)
{
var termsConds = Xrm.Page.getAttribute("new_termsconditions").getValue();
if(termsConds.length < 140) {
Xrm.Utility.alertDialog("The length of characters entered are less than the minimum requirement of 140 characters");
context.getEventArgs().preventDefault(); // cancel save
}
}
函数项和条件验证(上下文)
{
var termsConds=Xrm.Page.getAttribute(“新的条件”).getValue();
如果(术语长度<140){
Xrm.Utility.alertDialog(“输入的字符长度小于140个字符的最低要求”);
context.getEventArgs().preventDefault();//取消保存
}
}
谢谢Alex,在CRM Form events中加载或保存JS代码时,我在哪里运行此代码?这取决于您的要求这一切正常,但现在我收到一个错误,错误是:无法获取未定义或空引用的属性“getEventArgs”。请在表单编辑器中检查您的保存注册。“将执行上下文作为第一个参数传递”有一个复选框,应该选中它,是吗?(如果不是,请不要忘记,您需要发布更改才能使其生效。)