2

我需要制作多个验证摘要来验证他们的控件并显示任何错误消息。

我有一个很大的表格,我将它分成单独的面板,每个面板都有自己的验证组和摘要。我有一个按钮,它必须验证整个页面并导致所有验证组都被验证并显示错误消息。

我的想法是在后面的代码中迭代验证器/验证摘要/验证组的集合并触发它们的验证事件,但我无法实现它,以便验证摘要/错误出现在页面上。有任何想法吗?

编辑:我制作了一个 JavaScript 函数来尝试让它在客户端工作

<script type="text/javascript">
    function validate() {
        var t1 = Page_ClientValidate("vgpEmpInfo");
        var t2 = Page_ClientValidate("vgpPanelA");

        if (!t1 || !t2) return false;

        return true;
    }
</script>

但这仅验证并显示最后调用的验证组,在本例中为面板 A。

4

1 回答 1

0

So you are looking to do it all on the client then, not the server? The server would be easier as you could call Page.Validate("group"), and that would work for all the validation summaries.

Page_ClientValidate I didn't realize that would hide all the groups... but what you could try to do is call Page_ClientValidate for all. Now I'm not sure, but I think that it might just hide the <ul> representing the list, but I'm not 100% sure, so you may be able to just show all the <ul>'s representing each summary.... otherwise, you'd have to look at validatorValidate client method. Never done this, but seems like this might work, though the latter is going to be a real pain because you have to examine custom attributes on the validator span, and process accordingly.

HTH.

于 2011-05-13T01:44:26.613 回答