I have a form with a text input and I want to validate if the input contains a particular word. I've worked out how to validate for a specific string, but not just a word within that string.
$.validator.addMethod("exampleword", function(value, element, string) {
return value === string;
}, $.validator.format("Please enter '{0}'"));
$("#example-form").validate({
rules: {
address: {
required: true,
exampleword: "Foo"
}
},
messages: {
address: {
required: "Please enter an address",
exampleword: "Please include Foo"
}
}
})