Having trouble highlighting empty select2 selects when a form is submitted? I'm struggling to override my existing CSS styling upon document load.
Check out my jQuery attempt:
var $requiredUnfilledItems = $(".required:not(.filled)");
if ($requiredUnfilledItems.length > 0) {
$requiredUnfilledItems.each( function(){
$(this).addClass('warning-border');
});
}
Here's the CSS for .warning-border:
.warning-border {
outline: none !important;
border-color: red !important;
box-shadow: 0 0 10px red !important;
}
It's supposed to override this:
.select2-container--default .select2-selection--single {
width: 100%;
padding-left: 4px;
height: 100%;
border: thin solid lightgray;
height: 30px;
}
But it's not working. I've also attempted this, which may just show that I still have some CSS learning to do:
.warning-border, .select2-container.warning-border {
outline: none !important;
border-color: red !important;
box-shadow: 0 0 10px red !important;
}
Any help would be greatly appreciated!