JavaScript的检查,如果页面是否有效 [英] Javascript checking if page is valid

查看:171
本文介绍了JavaScript的检查,如果页面是否有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的提交按钮,我想要做的是的OnClick显示请稍候面板和隐藏按钮,除验证说点什么的无效 - 那么我需要的按钮依然明显呈现。否则,我有一个显示的错误及没有办法再次提交验证摘要。

大多数文章中,我找到这样想用Page_ClientValidate()函数来告诉页面来验证本身,而是这个来为我带回未定义一样,Page_IsValid变量。这里是我想要使用的功能 - 我缺少什么?

 函数PleaseWaitShow(){
    尝试{
        警报(PleaseWaitShow());        VAR isPageValid = TRUE;        //什么都不做,如果客户端验证未激活
        如果(typeof运算(Page_Validators)==未定义){
            如果(typeof运算(Page_ClientValidate)=='功能'){
                isPageValid = Page_ClientValidate();
                警报(Page_ClientValidate返回:+ isPageValid);
                警报(Page_IsValid =+ Page_IsValid);
            }其他{
                警报(Page_ClientValidate功能未定义);
            }
        }其他{
            警报(Page_Validators未定义);
        }        如果(isPageValid){
            //隐藏提交按钮
           。的document.getElementById('pnlSubmitButton')style.visibility ='隐藏';
           。的document.getElementById('pnlSubmitButton')的style.display ='无';           //显示请稍候面板
           。的document.getElementById('pnlPleaseWait')style.visibility ='可见';
           。的document.getElementById('pnlPleaseWait')的style.display =块;
       }其他{
           警报(页面无效 - 不显示请稍​​候);
       }
   }赶上(ER){
       警报(ERROR在PleaseWaitShow():+ ER);
   }
}


解决方案

我相信我已经找到了一个种的答案。

我现在还不能确定,为什么我的网页将无法识别Page_ClientValidate()或Page_IsValid - 这部分仍然没有答案

不过,我使用的验证程序的页面上的一些PeterBlum,而那些不提供返回true / false一个VAM_ValOnSubmit()。因此,这可能是该溶液中。我可能只是必须确保所有验证程序都PeterBlum,赶上他们。

不是最好的解决办法,但比我目前得到。我仍然愿意就了Page_IsValid部分答案。

On my submit button, what I'd like to do is OnClick show a "Please wait" panel and hide the button, UNLESS the validators say something's invalid - then I need the buttons still showing obviously. Otherwise I have a validation summary showing erros and no way to submit again.

Most articles I find about doing this want to use Page_ClientValidate() function to tell the page to validate itself, but this comes back undefined for me, as does Page_IsValid variable. Here is the function I'm trying to use - what am I missing?:

function PleaseWaitShow() {
    try {
        alert("PleaseWaitShow()");

        var isPageValid = true;

        // Do nothing if client validation is not active
        if (typeof(Page_Validators) == "undefined") {
            if (typeof(Page_ClientValidate) == 'function') {
                isPageValid = Page_ClientValidate();
                alert("Page_ClientValidate returned: " + isPageValid);
                alert("Page_IsValid=" + Page_IsValid);
            } else {
                alert("Page_ClientValidate function undefined");
            }
        } else {
            alert("Page_Validators undefined");
        }

        if(isPageValid) {
            // Hide submit buttons
           document.getElementById('pnlSubmitButton').style.visibility = 'hidden';
           document.getElementById('pnlSubmitButton').style.display = 'none';

           // Show please wait panel
           document.getElementById('pnlPleaseWait').style.visibility = 'visible';
           document.getElementById('pnlPleaseWait').style.display = 'block';
       } else {
           alert("page not valid - don't show please wait");
       }
   } catch(er) {
       alert("ERROR in PleaseWaitShow(): " + er);
   }
}

解决方案

I believe I've found a "kind of" answer.

I still cannot identify why my page will not identify "Page_ClientValidate()" or "Page_IsValid" - this part is still unanswered.

However, I am using a number of PeterBlum validators on the page, and those do provide a "VAM_ValOnSubmit()" that returns true/false. So this may be the solution. I might just have to be sure all the validators are PeterBlum to catch them all.

Not the greatest solution, but better than I've gotten so far. I'm still open to answers on the "Page_IsValid" portion.

这篇关于JavaScript的检查,如果页面是否有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆