bootrapValidation v3.1 worked fine validating CHOSEN drop downs. I initialized the JS file as follows:
//* Chosen Configuration & Initialization
var config = {
'.chosen-select' : {},
'.chosen-select-deselect' : {allow_single_deselect:true},
'.chosen-select-no-single' : {disable_search_threshold:10},
'.chosen-select-no-results': {no_results_text:'No restults found!'},
'.chosen-select-width' : {width:"95%"}
}
for (var selector in config) {
$(selector).chosen(config[selector]);
}
I recently installed the iCheck plugin, which has nothing to do with CHOSEN as far as I can tell, and was having issues getting the checkboxes to validate. I upgraded my bootstrapValidation to v4.2 and initialized iCheck as follows:
//* iCheck iRadio initialization
$('input').iCheck({
checkboxClass: 'icheckbox_square-blue',
radioClass: 'iradio_square-blue',
focusClass: 'focus',
increaseArea: '20%'
});
$('input').on('ifChecked', function(event){
$('input').iCheck('update');
});
I had to add the following JS to revalidate the checkboxes when needed:
//* Update validator if iCheck field changes
$('input').on('ifChanged', function(event){
var formId = this.form.id; //Get the ID attribute of the closest (current) form
var elementName = $( this ).attr("name");
$( '#'+formId )
// Get the bootstrapValidator instance
.data('bootstrapValidator')
// Mark the field as not validated, so it'll be re-validated when the user change date
.updateStatus( elementName, 'NOT_VALIDATED', null)
// Validate the field
.validateField( elementName );
});
This all worked great for iCheck and validated nicely. However, when I upgraded to boostrapValidation v4.2 my CHOSEN fields no longer would validate. I believe it is related to large amount of changes from bootstrapValidation v3.2 to v4.2. The only other change was adding iCheck plugin. That is why I mentioned that as well.
I need some help in validating CHOSEN fields in bootstrapValidation v4.2.
Here's a snippet of HTML5
...........
City, ZIP, County*
Alamo Beach, 77979, Calhoun
Algoa, 77517, Galveston
Alvin, 77511, Brazoria
Alvin, 77512, Brazoria
Amelia, 77707, Jefferson
Amsterdam, 77577, Brazoria
Anahuac, 77514, Chambers
Angleton, 77515, Brazoria
Aransas Pass, 78336, Aransas
Aransas Pass, 78336, San Patricio
Aransas Pass, 78336, Nueces
Armstrong, 78338, Kenedy asdfasdfadf
JQuery snippet:
$('#inspection').bootstrapValidator({
message: 'This value is not valid',
//* live: 'enabled',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
structureAddress: {
message: 'The structure address is not valid',
validators: {
notEmpty: {
message: 'The structure address is required!'
}
}
},
structureLocation: {
validators: {
notEmpty: {
message: 'Structure Location is required'
}
}
},
structureCityZipCounty: {
validators: {
notEmpty: {
message: 'Structure city, zip and county are required!'
}
}
},
structCitylimit: {
validators: {
notEmpty: {
message: 'City limit selection is required!'
}
}
},
structCobra: {
validators: {
notEmpty: {
message: 'Structure cobra required! Yes / No'
}
}
}
}
});
Thank you :)