[jQuery] JQuery Form Validation and Insert into Database problem

[jQuery] JQuery Form Validation and Insert into Database problem


I have two scripts, one validates the form and the other enters the
data into a SQL database without a page refresh. Both scripts work
fine on there own...
How can I combine them so the form validates and then inserts when
form is free of errors. Please see the two scripts below. I suspect it
be very easy but have been searching the net with no luck,
I am using the validate plugin from jquery.
<script type"text/javascript">
$(document).ready(function(){
$("#submit").validate ( {
showErrors: function(errorMap, errorList) {
$("#warning").html("Tu formulario contiene " +
this.numberOfInvalids() + " errores.");
this.defaultShowErrors();
},
debug: false,
errorElement: "em",
errorContainer: $("#warning"),
success: function(label) {
label.text("ok!").addClass("success");
}
});
    $("form#submit").submit(function() {
    // we want to store the values from the form input box, then send via
ajax below
    var fname = $('#fname').attr('value');
        $.ajax({
            type: "POST",
            url: "submit_data.php",
            data: "fname="+ fname,
            beforeSubmit: showRequest,
            success: function(del){
                $('td.success').fadeIn();
                $("#extra").hide();
                $("form#quickcheckbox INPUT[@name=checkme][type='checkbox']").attr
('checked', false);
                $('#submit').resetForm();
                setTimeout(function() { $("td.success").hide(); }, 4000);
            }
        });
    return false;
    });
});
</script>