How to use jquery validation plugin in rails

后端 未结 3 515
被撕碎了的回忆
被撕碎了的回忆 2021-02-06 19:49

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

3条回答
  •  梦毁少年i
    2021-02-06 20:14

    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();  
    }); 
    

提交回复
热议问题