【发布时间】:2018-02-25 22:08:27
【问题描述】:
我创建了一个自定义验证。在文档中我找到了方法addMethod()
我的例子:
Template.Login.onRendered(() => {
jQuery.validator.addMethod('strongPassword', (value, element) => {
return this.optional(element)
|| value.length >= 6
&& /\d/.test(value)
&& /[a-z]/i.test(value);
}, 'Your password must be at least 6 characters long and contain at least one number and one char.');
$('.login-form').validate({
rules: {
password: {
required: true,
strongPassword: true
}
}
});
});
我得到错误:
_this.optional 不是函数。检查元素时发生异常,检查'strongPassword'方法。
这是我的问题?
【问题讨论】:
标签: javascript jquery meteor