要使用门户网站的提交按钮在门户的最后一页进行评估,Microsoft提供了提交按钮应触发的功能“ webFormClientValidate”的扩展: https://docs.microsoft.com/en-us/dynamics365/customer-engagement/portals/add-custom-javascript。
我将此代码放在门户的最后一步:
console.log("alive");
if (window.jQuery) {
console.log("1");
(function ($) {
console.log("2");
if (typeof (webFormClientValidate) != 'undefined') {
console.log("3");
var originalValidationFunction = webFormClientValidate;
if (originalValidationFunction && typeof (originalValidationFunction) == "function")
{
console.log("4");
webFormClientValidate = function()
{
console.log("5");
originalValidationFunction.apply(this, arguments);
console.log("6");
// do your custom validation here
if (...)
{
console.log("7 false");
return false;
}
// return false;
// to prevent the form submit you need to return false
// end custom validation.
return true;
};
}
}
}(window.jQuery));
}
在页面加载中,日志写出: 活 1个 2 3 4
按下提交按钮应该触发“ webFormClientValidate”功能,但是什么也没有发生。未将“ 5”写入日志。有人知道为什么吗?
更新:从调试开始,页面似乎根本无法识别“ webFormClientValidate”。在搜索元素时,此人出现:
function webFormClientValidate() {
// Custom client side validation. Method is
called by the next/submit button's onclick event.
// Must return true or false. Returning false
will prevent the form from submitting.
return true;
}
我的研究表明,其他人只是粘贴相同的代码。巫婆告诉我,它应该以某种方式起作用: http://threads290.rssing.com/chan-5815789/all_p2645.html https://rajeevpentyala.com/2016/09/12/useful-jscript-syntaxes-adx-portal/ http://livingindynamics365.blogspot.com/2018/02/validating-user-input-in-crm-portals.html
答案 0 :(得分:0)
如果您使用实体表单,请使用entityFormClientValidate
代替webFormClientValidate