jquery validation plugin - different treatment for display errors vs. clearing errors
I am using the popular jQuery Validation Plugin. It's very flexible with regards to when validations are run (onsubmit, onfocusout, onkeyup, etc.).
When validations do run, as appropriate, errors are both displayed and cleared.
Without hacking the plugin core, I'd like a way to split the behavior so:
- Errors are only disp开发者_JS百科layed onsubmit
- But if the user subsequently enters a valid response, errors are cleared onsubmit, onfocusout, etc.
Just trying to create a better user experience: Only yell at them when they submit, yet still get the errors out of their face as soon as possible.
When I ran through the options, I didn't see the callbacks necessary to accomplish this. I'd like to make it work without having to hack the plugin core.
Anyone have some insights? Thanks.
I ended up solving this with a minor hack: At the appropriate place in the plugin, I fired a custom event. In my code, I bound to that event and used it in place of the callback I was looking for.
Probably could have used the prototype object as well.
精彩评论