Search code examples
ruby-on-railsruby-on-rails-3error-handlingclient-side-validation

Rails client side validations: how to show positive messages?


In the initializer of client_side_validations gem I can change field_error_proc to show error messages inline. But how can I show positive messages? For example, while user fills out password field I would show: "too short", "not bad", "secure" and add a green checkbox after user leaves the field.

EDIT: the password was just an example, not the best, what I really need it just to have 2 states valid/invalid for a field in the form, that the user filled out. The client_side_validations gem displays error messages if something goes wrong, if it's ok it displays nothing - and I'd like to show user that he's done it right.


Solution

  • I haven't had a chance to use the gem but the Callbacks should provide a way to achieve the functionality you deserve.

    clientSideValidations.callbacks.element.pass(element, callback, eventData) may be used to do additional processing if the form element has passed the validation.