0

How to validate list of input tag using bootstrap validator I am using spring, jquery and bootstrap

Here is my 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>

Here is my validator :

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

1 Answer 1

6

In rails,bootstrap validator plugin first Download the bootstrap-toggle-master file and copy and past validator.js or validator.min.js file in your project.

And add the following code in your view

{<%= 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 %>}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.