How to use jquery validation plugin for the rails form given below.
I want complete steps about how to make the it for different fields
Got the solution to add range ,min ,max etc
we have to use
<%= f.text_field :mobile,:class => "required number",:minlength=>"10",
:maxlength=>"10"%>
the above for mobile
First include the jquery validation file in your layout. Then in rails form add class to validation required fields as <%= f.text_field :firstname, :class => "required" %>. Then write a method with form_id to trigger the validation. That is you have to give like
$(document).ready(function () {
$("your_form_id").validate();
});
You can use the jquery validation rails gem based on jquery validation plugin. To use it
gem 'jquery-validation-rails'
On your app/assets/javascripts/application.js
add the following lines
//= require jquery.validate.additional-methods
//= require jquery.validate
$(document).ready
use $(document).on "turbolinks:load"
as described in turbolinks readme