jQuery Validate and AJAX submit...How to make them coexist?

jQuery Validate and AJAX submit...How to make them coexist?

How do you combine multiple jQuery plugins? I've found tutorials for doing this in ASP.NET but I need to know how to do it in PHP. I'm still pretty new to jQuery but it seems like it should be simple. Currently, I need to know how to combine an ajax posting script with the jQuery validation script found here. I've looked all over the internet for some tutorial (including this site) but cannot seem to find anything. Maybe I'm not looking hard enough but any help to point me in the right direction such as a tutorial or something would be greatly appreciated.

Basically what I want to do is validate a form and then send it to a mysql database so if there's an easier way to do this, that would also be great.

Here's the AJAX posting script I have so far:
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
   $("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');
   var lname     = $('#lname').attr('value');

      $.ajax({
         type: "POST",
         url: "ajax.php",
         data: "fname="+ fname +"& lname="+ lname,
         success: function(){
            $('form#submit').hide();
            $('div.success').fadeIn();
         }
      });
   return false;
   });
});
</script>


<div class="container">
<form id="submit" method="post">
      html form stuff
   </form>
<div class="success" style="display:none;">Client has been added.</div>
</div>


Ajax.php
<?php
        // where is your config file stored?
   include ("config.php");

   // CLIENT INFORMATION
   $fname        = htmlspecialchars(trim($_POST['fname']));
   $lname        = htmlspecialchars(trim($_POST['lname']));

    $addClient  = "INSERT INTO ajaxform (fname,lname) VALUES ('$fname','$lname')";
    mysql_query($addClient) or die(mysql_error());

?>

the code is from here.

Thanks![/code]