最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Page_ClientValidate is undefined in formview - Stack Overflow

programmeradmin4浏览0评论

I have validators inside a <asp:formview>, in order to show custom validation I am using

if (!Page_ClientValidate("groupName")) {}

I am getting an error Object Expected. How can I validate client side from the form view?

I use Page_ClientValidate for <asp:listview> and there

I have validators inside a <asp:formview>, in order to show custom validation I am using

if (!Page_ClientValidate("groupName")) {}

I am getting an error Object Expected. How can I validate client side from the form view?

I use Page_ClientValidate for <asp:listview> and there

Share Improve this question edited Jun 20, 2011 at 22:56 Town 14.9k3 gold badges50 silver badges72 bronze badges asked May 12, 2011 at 14:04 WilliamWilliam 211 silver badge2 bronze badges 2
  • Can you edit your question, it's a bit unclear. Is the code you're trying to run on the client (JavaScript) or the server (codebehind)? – Tom Robinson Commented May 12, 2011 at 14:17
  • The validation is client side. The validators are inside a form view. Validation for list view work fine. Why does the Page_ClientValidate throw this error when called from a button click from the form view? – William Commented May 12, 2011 at 15:28
Add a ment  | 

3 Answers 3

Reset to default 13

The Page_ClientValidate function may sometimes be undefined, e.g. if there are no validators on the page. Check if typeof Page_ClientValidate === "function" before calling it.

This would also occur if all validator's EnableClientScript properties are set to false.

Call the following Javascript function whenever you want and pass the validation group name of your form to it..

        function ValidateForm(ValidationGroupName)
        {
          var validated=Page_ClientValidate(ValidationGroupName); 
          if(validated)
          {
            //do the logic here
            return true;
          }
          else
          {
            return false;
          }
        }

Hope this will help you....

发布评论

评论列表(0)

  1. 暂无评论