slakoz wrote:
Dear All,

First of all the links to sample pages. First working sample:
http://www.torli.pl/valid/index-val.php

and (if someone want use this mix):
http://www.torli.pl/valid/valid.zip

Description (how i want it to work):
1. there are two tabs: tab #1 is enabled, tab #2 id disabled.
2. there are separate forms in two tabs
3. when the user fill the value in Field 1 in tab #1 and push Submit
button, tab #2 become enabled and triggered
4. if user leave empty Field 1 or for some reason validation of form1
in Tab #1 will be unsuccessfull then the warning message will show up,
form submit fails and tab #2 remain disabled

What is wrong:
the validation is working, because the message for Field1 validation
is displaying, but i can't figure out why the form is submited and
tab#2 enabled and triggered, when validation for Form1 in Tab1 is
unsuccessfull.

Thanks for any help or suggestions.
Best regards
Sławek


You need to validate the form in the beforeSubmit handler of the ajaxForm method, see here:

http://www.malsup.com/jquery/form/#code-samples (then choose tab "Validation")

Your example looks like:


$('form#dane_zam').ajaxForm({
    beforeSubmit: function {
        return $("#dane_zam").validate({
            ...
        });
    },
    target: '#result_dane_zam',
    success: function() {
        ...
    }
});

I'm not entirely sure about the validate initialization, especially if you need the submitHandler, because that is taken care of by the ajaxForm method depending on what is returned by validation. But I'm not too firm with the validate form plugin.

One more thing: You're putting the tabs init inside $(function() { }). You can remove this as you're already in a $(document).ready block.

$(function() {

});

is a shortcut for

$(document).ready(function() {

});

Thus instead of

$(function() {
$('#container-1').tabs({ fxSlide: true, fxFade: true, fxSpeed: 'fast', disabled: [2, 3, 4, 5, 6] });
});

just use

$('#container-1').tabs({ fxSlide: true, fxFade: true, fxSpeed: 'fast', disabled: [2, 3, 4, 5, 6] });

in your code.


--Klaus




Reply via email to