jQuery Validations

manuelmeurer edited this page Sep 12, 2010 · 6 revisions
Clone this wiki locally

Installation instructions

  • Install this plugin: ./script/plugin install git://github.com/augustl/live-validations.git
  • Download jQuery and the jQuery Validations jQuery plugin, and put them in RAILS_ROOT/public/javascripts.
  • Add <%= javascript_include_tag "jquery", "jquery.validate" %> to your layout(s).
  • Add LiveValidations.use :jquery_validations to an initializer (e.g. RAILS_ROOT/config/initializers/app.rb) or at the bottom of RAILS_ROOT/config/environment.rb.
  • Add :live_validations => true to the forms you want to live validate. Example: <% form_for(@user, :live_validations => true) %>

Configuration options

validator_settings: Any option here is passed directly onto the validate method in the javascripts. Refer to the documentation for a full list of what you can do here (it’s a lot). Example:

LiveValidations.use :jquery_validations, :validator_settings => {:debug => true, :onsubmit => false, :errorClass => "invalid"}