I have a text input called strCompanyName which I need to perform some validation on. Now I have the below working fine where I get a warning if the text in the input matches "Company", however, I am unsure how I would check to see if the input matches a number of values ie. "Company", "Your Company", "Your Company Name"
 jQuery.validator.addMethod("notEqual", function(value, element, param) {
 return this.optional(element) || value.toLowerCase() != param.toLowerCase();
}, "Please specify your company name");
$("form").validate({
  rules: {
    strCompanyName: { notEqual: "Company" }
  }
});
Any help would be greatful.
Change your custom validator to split on a symbol (say, pipe) and validate against the subsequent array:
http://jsfiddle.net/sw87W/40/
jQuery.validator.addMethod("notEqual", function(value, element, param) {
return this.optional(element) || param.toLowerCase().split('|').indexOf(value.toLowerCase()) < 0;
}, "Please specify your company name");
and
$("form").validate({
  rules: {
    strCompanyName: { notEqual: "Company|Another Company|Etc" }
  }
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With