Load validations on Div load

I have multiple Divs on my page(using updatepanel), only one visible at a time. on the third div, i have to implement validations using jquery.


<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery("#btn_Save").live("click", function () {
               jQuery("#form1").validate({
                   rules: {
                       '<%= txtUsername.ClientID %>': {
                           minlength: 2,
                           required: true
                       },
                       '<%= txtEmail.ClientID %>': {
                           required: true,
                           email: true
                       }
                   }, messages: {}
               });

               var prm = Sys.WebForms.PageRequestManager.getInstance();
               prm.add_initializeRequest(onEachRequest);
           });

       function onEachRequest(sender, args) {
           if (jQuery("#form1").valid() == false) {
               args.set_cancel(true);
           }
       }

    </script>      

and at the bottom of the page :

</form>
    <script type="text/javascript">
        function pageLoad() {
            fn_init();
        }
    </script>
</body>    

Now, the validation script is loaded on page load and does not fire when div is visible(on some button click). SO i need to load all the validation script on div load, or if somebody can suggest better way.

Answers


Try this

$("#form1").validate({ 
   ignore: ":hidden" 
});

Need Your Help

Add data from one table to another in ruby on rails

sql ruby-on-rails migration

In my current project, I have to get some data in a column of one table and put them to the 2nd table. The first table data have been saved as hash as follows:

Is there any tool create php proxy class for web service (wsdl)?

php wsdl

Hi Is there any tool for generating php proxy classes for webservice for php programming language? Web services are developed in .net. ThanksnRk

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.