4

i am working on bootstrap validation. on page load, form is showing. user can load and remove same form by add more/remove links. i have done this using jquery. To post data of all the forms, i am using array name like name="email[]".

i have done bootstap validation using bootstrap validator but it is not working. Any help please...

here is my bootstrap validator code

<script type="text/javascript">{literal}
$(document).ready(function() {
$('#save_form').bootstrapValidator({
    message: 'This value is not valid',
    feedbackIcons: {
        valid: 'glyphicon glyphicon-ok',
        invalid: 'glyphicon glyphicon-remove',
        validating: 'glyphicon glyphicon-refresh'
    },
    fields: {
        ind_email[]: {
            validators: {
                notEmpty: {
                    message: 'The email address is required and can\'t be empty'
                },
                emailAddress: {
                    message: 'The input is not a valid email address'
                }
            }
        }
    }
});
});

here is the html code

<form action="{$data.action}" method="post" enctype="multipart/form-data" name="save_form" id="save_form" class="form-horizontal"
    data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
    data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
    data-bv-feedbackicons-validating="glyphicon glyphicon-refresh">
<div class="form-group">
    <label class="col-sm-3 control-label">Email Address:</label>
    <div class="col-sm-5"><input type="text" name="ind_email[]" value="" id="email1" class="form-control"/></div>
</div>

Siguza
  • 21,155
  • 6
  • 52
  • 89
Dev001
  • 276
  • 1
  • 7
  • 25

1 Answers1

3

quotes are missing. Also, specify the group. Try this

'ind_email[]': { group: '.col-sm-5', validators: {

Vishal
  • 93
  • 10
  • @Vishal...it works only for first email address, its not validating other dynamically added block – Dev001 Feb 10 '15 at 07:05
  • you need to add validation at the time you are adding a new block dynamically. Try this $opt = $('#email'+number); // selector for a dynamic block $('#save_form').bootstrapValidator('addField', $opt); – Vishal Mar 03 '15 at 10:07