views:

44

answers:

1

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
  }
}
+1  A: 

You get passed the DOM node, not a jQuery wrapped version, so do this:

function someFunction(element) {
  var elementId = $(element).attr('id');
}
ivans