Using jquery form and validation plugins together

Using jquery form and validation plugins together

Hi

I'm new to jquery and struggling with my attempt to use the form plugin ( http://malsup.com/jquery/form/) and the validate plugin ( http://docs.jquery.com/Plugins/Validation) together on the same form.

I've got jquery form working perfectly, but have no idea what code to add to include validate on the same form.

Here's my script:

  1. <script type="text/javascript" src="/js/jquery-1.3.2.js"></script> 
  2. <script type="text/javascript" src="/jquery.form.js"></script> 
  3. <script type="text/javascript" src="/jquery.validate.js"></script> 
  4.  
  5.     <script type="text/javascript"> 
  6.       
  7. $(document).ready(function() { 
  8.   $('.spinner').hide();
  9.     var options = { 
  10.         target:        '#output1',   // target element(s) to be updated with server response 
  11. beforeSubmit:  showRequest,  // pre-submit callback       
  12. success:       showResponse  // post-submit callback 
  13.  
  14.     }; 
  15.  
  16.   $('#myform').ajaxForm(options); 
  17. }); 
  18.  
  19. function showRequest(formData, jqForm, options) { 
  20.     var queryString = $.param(formData); 
  21.  
  22.   $('#test_null_submit').hide();
  23.         $('.sub_spinner').show();
  24.     return true; 
  25.  
  26. function showResponse(responseText, statusText)  { 
  27.         $('.spinner').hide();
  28.         $('#pfh').hide();
  29.     </script> 

and a part of my form:

  1. <form class="contrib" name="contact" id="myform" method="post" action="process_form.asp">
  2. <fieldset>

  3. <label for="company" id="company_label">Company name *</label>
  4. <input type="text" name="company" id="company" class="input3 required" size="25" />

  5. <label for="address1" id="address1_label">Address</label>
  6. <input type="text" name="address1" id="address1" class="input3" size="25" />

  7. <input type="submit" name="submit" class="button" value="Submit" />

  8. </fieldset>
  9. </form>

The idea is to use the validate plugin to only submit if a company name is added.  I'm guessing I need to add something to the ShowRequest" function which is called BeforeSubmit - but I can't work out what to do.

Any help would be greatly appreciated.

Many thanks