jQuery Validate Not Equal


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. // Add method
  2. jQuery.validator.addMethod("notEqual", function(value, element, param) {
  3. return this.optional(element) || value != param;
  4. }, "Please specify a different (non-default) value");
  5.  
  6. // Use example
  7. $("#form").validate({
  8. rules: {
  9. nameField: { notEqual: "Your Name" }
  10. }
  11. });

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.