假设我有一个自定义AddMethod到jQuery Validate,如:
$.validator.addMethod('min-length', function (val, element) {
// do stuff
// the error message here needs to be dynamic
}, 'The field cannot be less than than '
+ element.attr('data-min') + // it is within the closure, but it can't grab it
' length.');
Run Code Online (Sandbox Code Playgroud)
我无法找到一种方法来获取有问题的元素变量,并从中获取任何值.我在这里错过了什么?