hi András,
I suppose that after 2 weeks you found a solution, but i was in the
same situation and I was thinking "too bad there is no answer to that :
("
So, now that I've found the solution, here it goes, for the next one.

1. i create the form's validation rules:
    $('#formId').validate({
        rules: {
            field1Id: {
                required: function() {
                    return $("#anotherFieldId").val() == 'the value I
want';
                }
            }
        }
    });

2. i create a checkForm function:
    function checkForm () {
        if (!$('#formId').valid()) {
            alert("Something is wrong in the form. Please check the
messages")
            return false;
        } else {
            return true;
        }
    }

3. Finally, I add a beforeSubmit (which trigger the checkForm
function) at the ajaxForm:
    $('#formId').ajaxForm( {
        beforeSubmit: checkForm
    } );

this is it :)
my sources: http://www.malsup.com/jquery/form/#code-samples and
http://www.chrillo.info/2008/10/14/jquery-ajaxform-and-validate-with-ajaxsubmit/
cheers


On Jul 5, 11:20 am, András Csányi <sayusi.a...@gmail.com> wrote:
> Hi all!
>
> I have a form and I want to validate before submit with [1] plugin
> because nice and good. I want to send the form's data with ajaxForm
> [2] plugin.
> The problem is the next:
> I set the ajaxForm options that before send the data validate. The
> validate plugin is working fine because I got error message(s) but the
> empty form was sended always.
>
> I want that while the form is not correct the ajaxForm don't send the data.
>
> Does know anybody example for this with these two plugins?
>
> Plugins:
> [1] -http://bassistance.de/jquery-plugins/jquery-plugin-validation/
> [2] -http://malsup.com/jquery/form/#getting-started
>
> Here is my simple code:
>
> <html>
>   <head>
>     <title>asd</title>
>     <script src="jquery.js"></script>
>     <script src="jquery.validate.js"></script>
>     <script src="jquery.form.js"></script>
>     <script>
>       $(document).ready(function() {
>         function formValidate() {
>           $("#formid").validate({
>             rules:{
>               asdasd: "required",
>               bsdbsd: "required"
>             },
>             messages:{
>               asdasd: "Ide kellene valamit írni!",
>               bsdbsd: "Ide se ártana balyétom!"
>             }
>           });
>         }
>         var ajaxFormOptions = {
>           beforeSubmit: formValidate()
>         }
>         $("#formid").submit(function(){
>           $(this).ajaxSubmit(ajaxFormOptions);
>           return false;
>         });
>       });
>     </script>
>   </head>
>   <body>
>     <form id="formid" action="post.php" method="post"
> enctype="multipart/form-data">
>       <p>
>         asdasd <input id="asdasd" name="asdasd" type="text">
>       </p>
>       <p>
>         bsdbsd <input id="bsdbsd" name="bsdbsd" type="text">
>       </p>
>       <p>
>         <input type="submit" value="submit">
>       </p>
>     </form>
>   </body>
> </html>
>
> I would like appreciate your kind help!
>
> --
> - -
> --  Csanyi Andras  --http://sayusi.hu-- Sayusi Ando
> --  "Bízzál Istenben és tartsd szárazon a puskaport!".-- Cromwell

Reply via email to