jackfranklin/jQuery-Form-Validator — pull request #2 by joshstrange (2012-11-05 15:50:22+00:00)
Title: Change runValidations() method to return jQuery objects for fields being validated

I was thinking it would really nice if the .runValidations() method returned the jQuery object for the fields that the validations were done to. This way people could go through those objects and make styling changes such as outline them in red if they didn't pass, make the background of the text box a shade of red, or even append elements to them with the message (Think: the ability to have little tool-tip-ish boxes over the input when you hover your mouse over it).

One of the things that originally got me excited about this validator is that it give the end user all the power without having to conform to how the validator wants to do things. Having the jQuery object there would really expand what is capable IMHO.

I would love to hear what everyone thinks and how they think it could be best implemented. I would be more than happy to help write the code and tests for it but I wanted to touch base before making large changes that I think people will want to weigh in on.

To get the ball rolling here is an example of what the runValidations() method could return:

Here is the default:

{
"messages": [],
"valid": true/false
}

I propose using something like this:

{
"fields": [
{
field: obj, //jQuery Object
messages: [] //Array of messages for the field
}
],
"valid": true/false
}

Of course fields would only be present in the the "fields" array if they had validation errors. Maybe a little later today, depending on how busy I am, I will edit the code so that I have a fully working example