【发布时间】:2016-03-24 06:04:34
【问题描述】:
我有一个带有文本输入的表单,我想验证输入是否包含特定单词。我已经研究出如何验证specific 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"
}
}
})
【问题讨论】:
标签: javascript jquery validation