Skip to content

Latest commit

 

History

History
61 lines (44 loc) · 1.35 KB

README.rdoc

File metadata and controls

61 lines (44 loc) · 1.35 KB

RailsJqValidations

Automatic client-side validation using jquery validation plugin.

What is this?

rails_jq_validations is a gem/plugin for Rails 4+ that enables client-side validation using jquery validation plugin. Once you bundle this gem on your app, the gem will automatically add the validation rules to form fields for jquery validation plugin.

How to Use?

add gem in gemfile

gem 'rails_jq_validations', git: "[email protected]:jbmyid/rails_jq_validations.git"

and run

bundle install

include js in your application.js

//= require rails_jq_validations/form_validator

add ‘data: {validate: true}` in your form_for helper eg:

<%= form_for @user, data: {validate: true} do |f| %>
  <%= f.text_field :name  %>
<% end %>

Or you can specifcally add rules for jquery validations eg:

<%= f.text_field :name, data:{jq-rules: {required: true}.to_json}%>

It includes following validations

  • presence

  • format

  • numericality

    • greater_than_or_equal_to

    • only_integer

    • greater_than

    • equal_to

    • less_than

    • less_than_or_equal_to

    • odd

    • even

  • inclusion

  • exclusion

  • length

    • is

    • minimum

    • maximum

Yes you are done!

Contributing

Fork it Create your feature branch (git checkout -b my-new-feature) Commit your changes (git commit -am ‘Add some feature’) Push to the branch (git push origin my-new-feature) Create new Pull Request