Rails 4 client side validation

后端 未结 5 2143
挽巷
挽巷 2021-01-01 22:40

Since upgrading my site to Rails 4, the client-side-validations gem has stopped working for me. I have had a look at the various alternatives such as jquery-validation-rails

相关标签:
5条回答
  • 2021-01-01 22:44

    From the Google.

    http://rubygems.org/gems/rails4_client_side_validations

    https://github.com/amatsuda/html5_validators

    Also this guy seemed to have gotten the same gem you are using to work by using the 4-0-beta branch.

    Client Side Validations and Rails4

    If the 4-0-beta branch works for you, consider helping to maintain the gem to keep it alive.

    To use a certain git repo version in your Gemfile:

    gem 'client-side-validations', :git => 'https://github.com/bcardarella/client_side_validations/tree/4-0-beta'
    
    0 讨论(0)
  • 2021-01-01 22:45

    I was able to use a fork of the original client_side_vlaidations that is very active at the moment. I am using the latest version of simple_form, rails 4.1.8, and this client_side_validations. Simple setup with basic config.

    0 讨论(0)
  • 2021-01-01 22:59

    I know the question is old, but how about good old require: "require"?

    For example in view:

    <%= f.text_area :body, placeholder: "Write your review here...", class: "form-control", rows: "5", required: "required" %>
    
    0 讨论(0)
  • 2021-01-01 23:00

    While the client side validations will work for the simple cases, they'll require an enormous amount of workarounds to work with more complicated scenarios (for instance - conditional validations). I would recommend using Judge instead, which give you more control.

    0 讨论(0)
  • 2021-01-01 23:00

    If you are using Bootstrap Form for Rails, you can give bootstrap_validator_rails a try.

    https://github.com/huynhquancam/bootstrap_validator_rails

    0 讨论(0)
提交回复
热议问题