如何使用数据属性覆盖Bootstrap的验证字形?

时间:2016-05-27 14:07:10

标签: twitter-bootstrap responsive-design overrides bootstrapvalidator

关于this documents

  

选项可以通过数据属性或JavaScript传递。对于数据属性,将选项名称附加到data-,如data-delay =""。

但是当我这样做的时候......

<input 
data-feedback-error="glyphicon-remove-circle"
type="email" pattern="\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[a-zA-Z]{2,}\b"
class="form-control" id="exampleInputEmail1" placeholder="Email" required/>

<input 
data-feedback="error:glyphicon-remove-circle"
type="email" pattern="\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[a-zA-Z]{2,}\b"
class="form-control" id="exampleInputEmail1" placeholder="Email" required/>

<span data-feedback-error="glyphicon-remove-circle"
  class="glyphicon form-control-feedback" aria-hidden="true"></span>

<span  data-feedback="error:glyphicon-remove-circle"
 class="glyphicon form-control-feedback" aria-hidden="true"></span>

...然后它不会覆盖glyphicon-remove的反馈错误默认值。

1 个答案:

答案 0 :(得分:0)

关于this answer,您必须使用特殊的引号样式将data-feedback - 属性写入表单标记:

  

<form ... data-feedback='{"success": "fa-check", "error":"fa-times"}'>

     

请注意引号语法