假设我有一个自定义 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.');
我想不出一种方法来获取有问题的元素变量,并从中获取任何值。我在这里想念什么?