0

jQuery Validation plugin has "element" argument for required rule. I know how to use it for inline functions but what if I want to pass it to out-of-line JS function? I tried this:

rules: { startHours: { required: startTimeRequired(element) },

but it didn't work.

1 Answer 1

1

You just reference the function itself, element is passed for you:

rules: { startHours: { required: startTimeRequired },

startTimeRequired() (if the parens are there) tells javascript to run the function then, which isn't what you want. You want to tell the required event handler to throw 'event' at startTimeRequired.

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.