Client side validations + Dynamic forms

Few things that might be helpful when working with client side validations. I am using client side validations in rails using gem

Client side validations

To validate forms dynamically added to the page, we need to use the validate function manually for that form.

For example:

If you dynamically render the following rails template into you view:

<%= form_for @model, :validate => true, :id => 'my_dynamic_form' do |f| %>
   <%= f.text_field :some_attribute %>
<% end %>


$("form#my_dynamic_form").validate();


Reset Validations

$("form#my_dynamic_form").resetClientSideValidations();

Comments

Popular posts from this blog

Interview Question on Ruby on Rails

Inserting and Moving elements inside Ruby Array