whatgoodisaroad / validity

Client-Side Validation for jQuery
http://whatgoodisaroad.github.io/validity/
132 stars 75 forks source link

Automatically close or fade-out error message when offending input is focused. #38

Closed cmanley closed 10 years ago

cmanley commented 10 years ago

I couldn't find how to do that in the documentation. Is it possible?

Also a nice to have feature would be to close/fade-out all error messages after a timeout.

whatgoodisaroad commented 10 years ago

That sounds like a great idea. I've added this as a feature in version 1.3.6.

You can activate it with $.validity.setup({ fadeOutTooltipsOnFocus:true });. It only works on the tooltip output mode.

Here's an example.

Fading out everything after a timeout is easier. Validity doesn't need to be modified, you can just put the following code in your validation function.

setTimeout(
  function() {
    $(".validity-tooltip").fadeOut();
  },
  3000
);