Dynamic jQuery Validate error messages with AddMethod based on the element
Posted
by
mcpDESIGNS
on Stack Overflow
See other posts from Stack Overflow
or by mcpDESIGNS
Published on 2012-11-12T22:28:51Z
Indexed on
2012/11/12
23:00 UTC
Read the original article
Hit count: 200
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?
© Stack Overflow or respective owner