首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在Dynamics 365门户中触发webFormClientValidate

如何在Dynamics 365门户中触发webFormClientValidate
EN

Stack Overflow用户
提问于 2018-06-20 16:01:37
回答 1查看 2.3K关注 0票数 2

为了使用提交按钮对门户的最后一页进行评估,微软为提交按钮应触发的函数"webFormClientValidate“提供了一个扩展:https://docs.microsoft.com/en-us/dynamics365/customer-engagement/portals/add-custom-javascript

我将此代码放在门户的最后一步中:

代码语言: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

按下submit按钮应该会触发"webFormClientValidate“函数,但是什么也不会发生。未将“%5”写入日志。有人知道为什么吗?

更新:从调试来看,页面似乎根本不能识别"webFormClientValidate“。然而,在元素中搜索,这个人出现了:

代码语言:javascript
运行
复制
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;
                        }

我的研究表明,其他人只是粘贴了相同的代码。Witch告诉我,它应该以某种方式工作: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

EN

Stack Overflow用户

发布于 2018-12-27 00:43:52

如果使用的是实体表单,请使用entityFormClientValidate代替webFormClientValidate

票数 4
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50943212

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档