title: JQuery Validate Writing Custom Function
body: <p>I have a form that I'm using jquery's validator to validate. If they entered Vendor into the registration code then they HAVE TO select vendor from the drop down menu. But ONLY for vendor, if they type college they don't have to select college from the drop-down menu. Here's the html part:</p>
  
  <pre><code>&lt;form id="everything" method="post"&gt;
  First Name:&lt;input type="text" name="fname" id="fname"/&gt;
  Last Name:&lt;input type="text" name="lname" id="lname"/&gt;
  &lt;select name="type" id="type"&gt;
    &lt;option value=""&gt;None&lt;/option&gt;
    &lt;option value="Early College"&gt;Early College&lt;/option&gt;
    &lt;option value="Public School"&gt;Public School&lt;/option&gt;
    &lt;option value="Vendor"&gt;Vendor&lt;/option&gt;
    &lt;option value="other"&gt;Other&lt;/option&gt;
  &lt;/select&gt;
  
  Registration Code: &lt;input type="text" name="regcode" id="regcode"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And then here's the jquery:</p>
  
  <pre><code>jQuery.validator.addMethod("registration_check", function(value, element) {
      if ($('#regis_code').val() == "Vendor") {
          return ($('#regis_code').val() == $('#iitype').val());
      }
  }, jQuery.format("You entered Vendor as the registration code, please select vendor from the Institutional Information Type drop down menu."));
  
  var val = $('#everything').validate({
      rules: {
          fname: { required: true},
          lname: { required: true},
          regis_code: {
              required: true,
              registration_check: true,
          }
      },
      messages: {
          regis_code: {
              required: "Please enter a registration code"
          }
      }
  });​
  </code></pre>
  
  <p>If I type in vendor and don't select vendor from the drop-down menu it whines, which is good. The problem is, if i type vendor and select it from the dd menu and nothing for the first and last name (which have to be filled out), it fails to validate the names and just moves on. Does anyone know what the problem is?</p>
  
  <p>Edit: Here's a working example of the problem: <a href="http://jsbin.com/welcome/54612/edit" rel="nofollow">BIN</a>. To reproduce the problem, just type vendor into the registration code text box, then select vendor from the drop down and click submit. This will show you how it fails to validate the other two text boxes.</p>