Validation: Only validate textbox if corresponding checkbox checked

Validation: Only validate textbox if corresponding checkbox checked

I have a simple form which I am running a validation on a single text box (as shown below, adapted from the milk example).

  1.  $(document).ready(function() {
  2. // validate signup form on keyup and submit
  3. var validator = $("#updateModules").validate({
  4. rules: {
  5. guestbookContact: {
  6. required: true,
  7. email: true
  8. },
  9. },
  10. // the errorPlacement has to take the table layout into account
  11. errorPlacement: function(error, element) {
  12. if ( element.is(":radio") )
  13. error.appendTo( element.parent().next().next() );
  14. else if ( element.is(":checkbox") )
  15. error.appendTo ( element.next() );
  16. else
  17. error.appendTo( element.parent().next() );
  18. },
  19. // specifying a submitHandler prevents the default submit, good for the demo
  20. submitHandler: function() {
  21. form.submit();
  22. },
  23. // set this class to error-labels to indicate valid fields
  24. success: function(label) {
  25. // set   as text for IE
  26. label.html(" ").addClass("checked");
  27. }
  28. });
Now I only want to validate the text box if the checkbox "requireEmail" is checked. Is there an easy way to do this?