[EMAIL PROTECTED] escribió:
@JOSE

I wrote this code that is working but  I think there is a better way:

$(document).ready(function(){
                                $("#treeform").validate({
                                        errorContainer: $("#messageBox1"),
                                        errorLabelContainer: $("#messageBox1 
ul"),
                                        wrapper: "li",
                                        submitHandler: function(){
                                                $
('.loading').removeClass('loading');
                                                $(this).submit();
                                        }
                                });
                        });

What do you think???
One simple question, if you want submit the form with the normal way (without AJAX), why do you need remove classes and submit? if the validation is correct, automatically, the form is submitted so, the page is reloaded (or another page is loaded), you don't need a submitHandler and change the view of the page with JavaScript because the view is
refreshing when the form is submitted.

Also, in the plugin documentation, I can see that submitHandler has one argument, the
form, no this reference, so:

$(document).ready(function(){
 $("#treeform").validate({
   errorContainer: $("#messageBox1"),
     errorLabelContainer: $("#messageBox1 ul"),
     wrapper: "li",
   submitHandler: function(theform){
     $('.loading').removeClass('loading');
theform.submit(); //submit is a native method, better than jQuery trigger method submit()
   }
 });
});
Thanks

Andrea

--
Best Regards,
José Francisco Rives Lirola <sevir1ATgmail.com>

SeViR CW · Computer Design
http://www.sevir.org
Murcia - Spain

Reply via email to