Return to Snippet

Revision: 58358
at July 11, 2012 01:54 by StevenW721


Initial Code
// Add method
jQuery.validator.addMethod("notEqual", function(value, element, param) {
  return this.optional(element) || value != param;
}, "Please specify a different (non-default) value");

// Use example
$("#form").validate({
  rules: {
    nameField: { notEqual: "Your Name" }
  }
});

Initial URL
http://stackoverflow.com/questions/3571347/how-to-add-a-not-equal-to-rule-in-jquery-validation

Initial Description
Adds a method to the jQuery Validation plugin (http://bassistance.de/jquery-plugins/jquery-plugin-validation/) to return false if the field equals a specified string

Initial Title
jQuery Validate Not Equal

Initial Tags
javascript, jquery

Initial Language
PHP