Reputation: 4920
I have my form and validation working great with regular http requests. I would like it to use AJAX. I know i can validate on the client side but that seems redundant given that I have defined the validations in my model.
As the user is filling out the form, I'd like to give feedback to them on their entries. What is the best way to use the rails defined validations in an AJAX form and give live feedback?
Upvotes: 5
Views: 7713
Reputation:
https://github.com/augustl/live-validations/wiki has installation instructions.
When you add LiveValidations.use :jquery_validations
to the bottom of your environment.rb, make sure it is outside of the Rails::Initializer block.
Upvotes: 0
Reputation: 762
For Rails 3 check out Client Side Validations: https://github.com/bcardarella/client_side_validations
Here's the railscast: http://railscasts.com/episodes/263-client-side-validations
Upvotes: 5
Reputation: 536
If you're looking for a solution to this that does not introduce any plugin dependencies check out my screencast on the issue:
AJAX Validations on Rails 2.3.8
Upvotes: 1
Reputation: 101
Live-validations was kinda messy to get working for me, so I started with my own solution from scratch backed by Validatious. It's actually really DRY because of the Rails conventions in the back that made it possible to do a lot of smart assumptions. In most cases, all you need is to include a few javascript dependencies and declare your validations in your models as always - and it all just works! =) Peep the README for details.
Here it is:
http://github.com/grimen/validatious-on-rails
Upvotes: 2
Reputation: 176552
Check out the live-validations plugin. There's also an introductory screencast.
Upvotes: 5