Jose, I understand your doubts and yes normally I should not care to change page layout if validation is ok. Problem is that this tricks need me in a quite complicate application control panel that elaborate quite a lot of info ( page reload in 4/5 seconds). To change it to Ajax mode takes me now too long time ( I will do in future ) so my options to make it nicer is to at least displaying a loading bar ( maybe a modal one ) to prevent user to double click or making other strange operation with risk of data corruption.
Thanks for your help Andrea On 5 sep, 01:31, SeViR <[EMAIL PROTECTED]> wrote: > [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