title: trying to create a validation function for custom js code
body: <p>i have this function</p>
  <pre><code>function validateAndSend() {
  if (frmVendor.CompanyName.value == '' &amp;&amp; frmVendor.LastName.value == '') {
  alert('You have to enter a Company Name or an Individual First and Last Name.');
  return false;
  }
  else if(frmVendor.CompanyName.value != '' &amp;&amp; frmVendor.LastName.value != ''){
  alert('The Vendor has to be either a Company or an Individual, but not both.');
  return false;
  }
  else if(frmVendor.CompanyName.value != '' &amp;&amp; frmVendor.FirstName.value != ''){
  alert('The Vendor has to be either a Company or an Individual, but not both.');
  return false;
  }
  else {
  frmVendor.validate(formObj());
  frmVendor.submit();
  }
  }
  </code></pre>
  <p>i tried like this and it seems i am missing some key parts here about the code i am writing but how can i make it work,</p>
  <pre><code>$.validator.addMethod( &quot;comparedata&quot;, function( value, element ) {
      if(element.CompanyName.value == '' &amp;&amp; element.LastName.value == '') {
          txt = 'You have to enter a Company Name or an Individual First and Last Name.'
      } else if(frmVendor.CompanyName.value != '' &amp;&amp; frmVendor.LastName.value != ''){
      txt = 'The Vendor has to be either a Company or an Individual, but not both.';
      return false;
      }
      else if(frmVendor.CompanyName.value != '' &amp;&amp; frmVendor.FirstName.value != ''){
      txt = 'The Vendor has to be either a Company or an Individual, but not both.';
      return false;
      }
  return txt
  });
  </code></pre>
  <p>but its not working properly and i am trying to add them as <code>data-attributes</code></p>