I have select2 customized via css with its general classes and ids.
Now, I\'m trying to customize a specific class that will be provided to select2 and then apply in css
It will depend on the version of select2 that you are using. The html structure changed in one of the versions.
Here is Fiddle example: https://jsfiddle.net/LpjcqbLu/
I just put the 'error' class on the select box.
.error + .select2-container,
.error + .select2-container + .select2-container .select2-dropdown {
border: 3px solid red !important;
}
In earlier versions, the dropdown was not close to the select box (in the dom), so you would have to do a javascript solution to apply the error class directly.