【问题标题】:How to validate list of input tag using bootstrap validator如何使用引导验证器验证输入标签列表
【发布时间】:2014-11-09 12:18:03
【问题描述】:

如何使用引导验证器验证输入标签列表 我正在使用 spring、jquery 和 bootstrap

这是我的html:

<form id="myForm" class="form-horizontal" method="post" action="/hello">

<input class="form-control" type="text" name="myobject[0].descripton />
<input class="form-control" type="text" name="myobject[1].descripton />
<input class="form-control" type="text" name="myobject[2].descripton />
<input class="form-control" type="text" name="myobject[3].descripton />

</form>

这是我的验证器:

$('#myForm').bootstrapValidator({
  feedbackIcons : { 
    valid : glyphicon glyphicon-ok,
    invalid : glyphicon glyhicon-remove
    validating : glyphicon glyphicon-refresh 
  },

  fields : {
    myobject[].description : {                 // <---name of tag.
      validators : {
        notEmpty : {
          message : 'this is required'
        }
       }
    }
  }
});

【问题讨论】:

    标签: javascript jquery spring twitter-bootstrap validation


    【解决方案1】:

    在rails中,bootstrap验证器插件首先下载bootstrap-toggle-master文件并复制过去的validator.js或者validator.min.js文件到你的项目中。

    并在你的视图中添加以下代码

    {<%= form_tag({controller: "facebook", action: "post_message", method: "post"}, :data => {:toggle => "validator"},:class => "facebook-post") do %>
              <div class="form-group">
               <label for="exampleInputEmail1">Please write something for your status and our wall</label>
                <%= text_area_tag :status_message, nil, class: "form-control", :rows => 3, :required => 'true', :data => {:error => "Please write something for both your status and our wall. E.g. Thanks very much for a great night."}%><div class="help-block with-errors"></div>
    
                <% if @venue_location.present? %>
                    <small>- at </small><%= link_to @venue_location, @fb_page, target: '_blank' %>
                <% end %>
              </div>
    
              <% if ((@package == 'package3') && !(@fb_page.blank?)) %>
                  <div class="facebook-like">
                    <div class="fb-like"
                         data-href="<%= current_venue.facebook_page %>"
                         data-layout="standard"
                         data-action="like"
                         data-show-faces="false"
                         style="overflow: hidden">
                    </div>
                  </div>
              <% end %>
    
              <div class="btn-next text-right">
                <%= image_submit_tag("customer/icon-forward.png") %>
              </div>
        <% end %>}
    

    【讨论】:

      猜你喜欢
      • 2020-04-06
      • 1970-01-01
      • 2023-03-13
      • 2016-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-08
      • 1970-01-01
      相关资源
      最近更新 更多