Skip to content

jbmyid/rails_jq_validations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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: "git@github.com: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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published