Bootstrapvalidator doesn't work on select2.js
my code doesn't validate select. what's wrong there ?. what the solution of this ? sorry for my bad english, and thanks a lot for the answer
Here my form
<form name="form_tambah" class="form_tambah">
<div id="tambah" class="col-md-5">
<h4>Tambah Data Kabupaten</h4>
<div class="form-group form-group-select2">
<select name="s_propinsi" id="s_propinsi" class="form-control" data-live-search="true">
<option value="">Pilih Propinsi</option>
<?php
foreach($propinsi as $p) {
echo('<option value="'.$p->prop_id.'">'.$p->prop_name.'</option>');
}
?>
</select>
</div>
<div class="form-group">
<input type="text" name="name_kab" class="form-control" id="name_kab" placeholder="Nama Kabupaten"/>
</div>
<button id="bt_tambah" class="btn btn-primary" ><span class="fa fa-fw fa-save"></span> Simpan</button>
</div>
</form>
My Javacript
<script>
$(document).ready(function(){
init();
});
function init(){
$('#s_propinsi').select2({
allowClear: true
});
$('#s_kab_2').select2();
valid_tambah();
valid_edit();
}
function valid_tambah(){
$('.form_tambah').bootstrapValidator({
message: 'This value is not valid',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
s_propinsi: {
validators: {
notEmpty: {
message: 'Required'
}
}
},
name_kab: {
validators: {
notEmpty: {
message: 'Required'
}
}
}
}
})
.on('success.form.bv', function(e) {
exc_add();
});
}
</script>
ignore it: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sed risus et ex mollis dictum. Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec id interdum purus, a egestas urna. Ut ut volutpat tellus, eget congue neque. Nam a rutrum nisl. Donec augue metus, molestie ut mi nec, commodo laoreet sem. Quisque nulla metus, fermentum non vehicula quis, sagittis et sapien. Morbi dictum porta massa, at hendrerit urna tincidunt vel. Praesent sit amet eros in leo imperdiet varius.
You need to add an attribute for the validator.
base.validator({
excluded : [":disabled"]//Just this attribute
}, "#addForm", self.create, panel)};
链接地址: http://www.djcxy.com/p/88586.html上一篇: jQuery xy文档坐标的DOM对象