I've written the following simple rule for jQuery Validation:
jQuery.validator.addMethod("notEqual", function(value, element, param)
{
return this.optional(element) || value != param;
}, "This field is required");
This works such that I can say:
$("#form").validate({
rules:
{
field1: {notEqual: "Please Select", required: true},
field2: {notEqual: "Year", required: true}
},
messages:
{
field1: {
notEqual: "This field is required",
required: "This field is required"
}
field2: {
notEqual: "This field is required",
required: "This field is required"
}
},
submitHandler: function(form) {
form.submit();
}
});
However I want to be able to say that any one field is not allowed to be equal to multiple things e.g.
field1: {notEqual: "Please Select" || "Year" || "Some Value", required: true},
But I have tried this syntax as well as a few other ways of arranging the "ÖR" operator and none of them work. Can anyone help? Thanks.