jQuery: code to validate before submitting

jQuery: code to validate before submitting

Hi,

I'm trying to validate my form before submitting it. I'm trying it with this code below, but it always submit the form values:

$('#gestione_profilo').submit(function () {

    $

("#gestione_profilo").validate({

        rules

: {

           

'person_data[document_number]': "required"

       

},

        messages

: {

           

'person_data[document_number]': "required"

       

}

   

});


    form_data


= $(this).serialize();

    $

.ajax({

        url

: "<?php echo url_for('profile/index') ?>",
        type
: "POST",
        data
: form_data,
        success
: function() { $("#forma_profile").unmask(); }

       

});

        $

("#forma_profile").mask("Aggiornando dati...");

       

return false;

   

});

Any help?

Regards

Javier