Could you post a complete testpage? Looks like your extracts are
missing something...

Jörn

On Wed, Jan 14, 2009 at 12:00 AM, Fledder <ferdy.christ...@gmail.com> wrote:
>
> hi,
>
> Like others I seem to have ran into the "double-click to submit
> problem". Allow me to explain:
>
> I have a registration form which validates just fine using the
> excellent validate plugin. It's working perfectly. However, I now want
> to run some custom code after the validation event. Specifically, I
> want to disable the submit button when validation is passed. After
> that, a normal post should follow to the server, no Ajax post.
>
> My first try was to do this:
>
> // disable the submit button upon submit event
> $("#frmEditUser").submit(
>        function()      {
>           $("#submSave").attr("disabled","true").attr("value", "Updating,
> please wait...");
>        }
> );
>
> // validation code follows here
> $("#frmEditUser").validate({
> ......
>
> This indeed changes the submit button and validation still works.
> However, it does not submit the form to the server, instead, nothing
> happens. My 2nd try was to use the validation plugin's submitHandler.
> Mind you this code is a bit long, but I think only the bottom part is
> relevant:
>
> $("#frmEditUser").validate({
>                onkeyup:false,
>                rules: {
>                        username: {
>                                required:true,
>                                minlength:5,
>                                maxlength:45,
>                                validChars:true,
>                                
> usernameCheck:[$("#username").val(),oldusername]        // remote check
> for duplicate username
>                        }
>                },
>                messages: {
>                        username: {
>                                required: "username is required.",
>                                minlength: jQuery.format("username must be at 
> least {0} characters
> in length."),
>                                maxlength: jQuery.format("username can not 
> exceed {0} characters
> in length."),
>                                validChars: "please supply valid characters 
> only.",
>                                usernameCheck:"this username is already in 
> use."
>                        }
>                }
>                ,
>                submitHandler: function(form) {
>                        // do other stuff for a valid form
>                        $("#submSave").attr("disabled","true").attr("value", 
> "Updating,
> please wait...");
>                        form.submit();
>                }
>
>        });
>
> This approach I have seen elsewhere in the forum, but it does not work
> for me. Validation runs fine, yet when the form is valid it once more
> does not actually post it to the server. It does post when I double-
> click (only when I uncomment the button-disabling code, otherwise I
> cannot double-click).
>
> So my question in general is: how can I have my own custom submit code
> that does not conflict with the validation plugin and that does an
> actual post? I thoroughly looked through the forum but I still do not
> see the solution.
>
> I will be very grateful for a solution, I've spent so many precious
> hours on accomplishing such a small thing (disabling a submit button).
> Thanks in advance!
>

Reply via email to