2017-02-01 50 views
0

我有一个select2选择菜单。Bootstrap select2错误样式

剥离版本,例如:

<div class="form-group has-error"> 
     <select name="description_id" class="select2"> 

// <options> 

</div> 

运用has-error到文本输入将显示围绕输入一个红色边框。这对于s​​elect2菜单不起作用。我错过了什么?

我使用bootstrap3和最新选择2:

https://select2.github.io/

我读过这个页面,并试图解决方案,但它不工作:

https://xcellerant.net/2013/12/05/adding-bootstrap-error-styling-to-a-select2/

回答

5

的解决方案在您发布的页面上,适用于旧版本select2。最新的版本,使用这个CSS代码在这里:

.has-error .select2-selection { 
    border-color: rgb(185, 74, 72) !important; 
} 

现在有了这个代码,并使用has-error类,你可以得到适当的偏红错误颜色:

​​

Select2 with has-error class

的jsfiddle例如:https://jsfiddle.net/k9phxgnd/1/

+0

就是这样,非常感谢,可以在12小时内奖励赏金:-) – Hardist