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 Answer 1

1

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

function someFunction(element) {
  var elementId = $(element).attr('id');
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.