HenrikJoreteg/Happy.js — pull request #40 by smilli (2014-04-25 18:30:38+00:00)
Title: Refactor triggering of form validation

This is a response to #39. It makes sense to not have error messages disappear when the blur event occurs. But while we're talking about UX for error handling, it also feels weird to have to click away from the input to make an error disappear in general. Would it be better to have fields be validated by default on both blur and keyup?

The only weird issue I see with this is having a field be validated while the user is typing for the very first time. That is if I'm typing in my email I don't want to get an error the first time I put in 's'. So basically after the first blur event is when keyup validation should start.

And if by default forms are validated on multiple events, users should be able to pass in multiple events as well, so I made the 'when' option compatible with arrays.

This isn't mergable yet, just wondering if people think this is a good idea before I finish this up & add tests.

Changes:
-Validate required fields not just on submit
-Validate on blur and keyup by default instead of just blur
-Allow users to pass in array of events for validation to occur on