Rails form validation does not work if form is initially hidden -


i having weird issue rails form validation. validation works fine if form visible when page loads nothing happens if form hidden , displayed upon user interaction page.

model

class pushnotification < activerecord::base   belongs_to :application, foreign_key: :appid, primary_key: :appid    validates :message, :presence => true, :length => { maximum: 75 }   validates :max_message_frequency, :presence => true, :numericality => {:only_integer => true, :greater_than => 0}   validates :appid, :presence => true end 

html form

<div id="push-message-tab" class="tab-section">     <%= form_for(pushnotification.new,                      url: messaging_messaging_cohort_create_push_path(@application, @cohort),                      remote: true, validate: true,                      html: {                              id: :push_notification_create_form,                              class: 'new_push_notification_create ' + (@cohort.new_record? ? 'default-segment' : ''),                              autocomplete: "off"                      }) |f| %>               <div class="push-form-component-header">               <%= f.label :message, 'message' %>               <span id="message-char-counter-wrapper"><b id="char-counter">75</b> characters left</span>             </div>             <div class="actions">               <%= f.submit "save", id:'submit-push', class: 'with-spinner', data: {waiting_text: "saving"} %>             </div>     <% end %> </div> 

if push-message-tab element visible when page loads rails form validation works great doesn't when specify style="display: none" , toggle visibility option on fly. form sent without performing sort of validation.

i using rails 3.1 ruby 1.9.2

thank support

you seem using client_side_validations gem.

based on documentation (https://github.com/bcardarella/client_side_validations) , assuming talking client-side validations recommend trying in javascript:

$('#your_form').resetclientsidevalidations(); 

just after set form being displayed.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -