Bootstrap validation on dynamically added fields of the same array name (input attribute), eg name = "email []"
I am working on validating bootstrap. the page is loaded, the form is displayed. user can load and remove the same form by adding / removing links. I did it using jquery. To publish all form data, I use the array name, for example name = "email []".
I did bootstap validation with bootstrap validator, but it doesn't work. Any help please ...
here is my bootstrap authentication 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>
+3
source to share