title: jQuery validator plug-in: validate optional field
body: <p><strong>Problem</strong>
  I want to validate a field using a custom validator I've created that's essentially a regex for a phone number only IF the field has a value, otherwise it doesn't need to be validated because it's optional.</p>
  
  <p>Custom validator:</p>
  
  <pre><code>   $.validator.addMethod('phone', function (value) {
         return /^[01]?[- .]?\(?[2-9]\d{2}\)?[- .]?\d{3}[- .]?\d{4}$/.test(value);
     }, 'Please enter a valid US phone number.');
  </code></pre>
  
  <p>Rules:</p>
  
  <pre><code> phone: {
    required: true,
    phone: true
   },
   fax: {
    phone: true
   }
  </code></pre>
  
  <p>I've even tried:</p>
  
  <pre><code> phone: {
    required: true,
    phone: true
   },
   fax: {
    required: function(element){
     if (!$("#cf-fax").val()) { return true; } else { return false; }
    }
    phone: true
   }
  </code></pre>
  
  <p>For reference this is the field I'm trying to reference:</p>
  
  <pre><code>&lt;input type="text" name="fax" class="optional" size="15" maxlength="14" id="cf-fax" /&gt;
  </code></pre>
  
  <p>Any help is appreciated because I am just plain lost.  =\</p>