[英]CRM Dynamics 2013 JavaScript Validate Minimum characters in free text field
我有一個簡單的驗證,需要在強制用戶在字段中包含最少字符的表單上執行,我具有以下代碼,如下所示,但它不起作用,我在加載和加載時嘗試了保存事件但沒有運氣,請協助。
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");
}
}
如果new_termsconditions
是text類型(單行或多行),則可以像下面這樣簡單地修復代碼:
if(TermsandCon.length < 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
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.