我需要使用 jquery validate 来验证 textarea。我正在寻找正则表达式来检查由空格分隔且长度超过 5 个字符的多个带引号的字符串..:
“引用的文本..” “一些其他引用的文本” “另一个引用的字符串” = 好
“引用的文本..” “” “另一个引用的字符串” = 不好
“引用文本..” “abcd” “另一个引用字符串” = 不好
以下仅检查第一个引用的文本...(“引用的字符串长于 5”“”-> 这通过但不应该)
$(document).ready(function()
{
$.validator.addMethod("coll_regex", function(value, element) {
return this.optional(element) || /"(.*?)"/.test(value);
}, "Message here......");
$("#f_coll").validate(
{
rules:{
'coll_txt':{
required: true,
minlength: 5,
maxlength: 200,
coll_regex: true
}
},
messages:{
'coll_txt':{
required: "Textarea is empty...",
minlength: "Length must be, at least, 5 characters..",
maxlength: "You exceeded the max_length !",
coll_regex: "Use the quotes...."
}
},
errorPlacement: function(error, element) {
error.appendTo(element.next());
}
});
});
有没有这样做的正则表达式???会很棒...谢谢