Dynamic jQuery Validate error messages with AddMethod based on the element
- by mcpDESIGNS
Let's say I have a custom AddMethod to jQuery Validate like:
$.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.');
I can't figure out a way to get the element variable in question, and get any values from it. What am I missing here?