如何使用客户端验证gem以嵌套形式使用客户端代码验证

时间:2014-03-07 09:16:52

标签: javascript ruby-on-rails

如何以嵌套形式使用客户端验证。我正在使用客户端验证gem。

我的代码是

<%=nested_form_for @hands_played, :url => { :controller => "hands_played",:action => "create"  },:validate=>true, :method => :post do |f|%>

<div class="prettyprint prettypadding">
    <h3>Add Hands Played</h3>

    <center>
        <div class="span9">
            <div class="span9"> <label class="fg-color-darken span3 place-left text-left">Title</label> 
                <span class="fg-color-darken span5 place-left text-left">
                <div class="input-control text">
                        <%= f.text_field :title, :validate=>true %>
                        <p class="h_p_title error"></p>
                </div>      
                    </span>
            </div>

            <div class="span9"> <label class="fg-color-darken span3 place-left text-left">Story</label> 
                <span class="fg-color-darken span5 place-left text-left">
                    <div class="input-control textarea">
                        <%= f.text_area :story, :rows=>6, :validate=>true %>
                        <p class="h_p_story error"></p>
                    </div>
                    </span>
            </div>



            <div class="span9"  style="overflow: hidden; position: relative;"> 
                <label class="fg-color-darken span3 place-left text-left">Link To Blog</label>
                <span class="fg-color-darken span6  place-left text-left">
                <%= f.fields_for :hands_played_bloglinks,:validate=>true  do |link_blog| %>
                <div Style="border:0;" id="bloglinkID" class="span6">   
                        <div class="input-control text span5 place-left ">
                            <%= link_blog.text_field :blog_url %>
                        </div>  
                        <div class="span1 place-left" style="padding-top: 20px;">
                            <%= link_blog.link_to_remove "", :style=>"",:validate=>true, :class=>"icon-minus" %>
                        </div>

                </div>
                <% end %>
                    </span>
                <span  style="position: absolute; right: 64px; top: 20px;"> 
                    <%= f.link_to_add "", :hands_played_bloglinks, :class=>"icon-plus",:style=>"font-size: 14px;", :data => { :target => "#bloglinkID" } %>
                </span>

            </div>
<%end%>

0 个答案:

没有答案