我试图在http://jqueryvalidation.org/reference/
中实施“重构规则”部分但问题是,我不知道在哪里放置$ .validator代码。现在,我正在添加
// alias required to cRequired with new message
$.validator.addMethod("cRequired", $.validator.methods.required,
"Customer name required");
// alias minlength, too
$.validator.addMethod("cMinlength", $.validator.methods.minlength,
// leverage parameter replacement for minlength, {0} gets replaced with 2
$.format("Customer name must have at least {0} characters"));
// combine them both, including the parameter for minlength
$.validator.addClassRules("customer", { cRequired: true, cMinlength: 2 });
文档加载后,但它似乎不起作用。接下来,我尝试将其添加到jquery validate javascript文件本身,但没有运气。任何帮助表示赞赏。