jQuery Validate Element
jQuery Validate plugin passes element value to inline开发者_开发技巧 validate functions. I'm trying to get element's id and an error telling that "element.attr is not a function" :
function someFunction(element) {
var elementId = element.attr('id');
}
rules: {
someFiled: {
required: someFunction
}
}
You get passed the DOM node, not a jQuery wrapped version, so do this:
function someFunction(element) {
var elementId = $(element).attr('id');
}
精彩评论