9 * @class Roo.bootstrap.FieldLabel
10 * @extends Roo.bootstrap.Component
11 * Bootstrap FieldLabel class
12 * @cfg {String} html contents of the element
13 * @cfg {String} tag tag of the element default label
14 * @cfg {String} cls class of the element
15 * @cfg {String} for label target
16 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
17 * @cfg {String} invalidClass default "text-danger fa fa-lg fa-exclamation-triangle"
18 * @cfg {String} validClass default "text-success fa fa-lg fa-check"
21 * Create a new FieldLabel
22 * @param {Object} config The config object
25 Roo.bootstrap.FieldLabel = function(config){
26 Roo.bootstrap.Element.superclass.constructor.call(this, config);
31 * Fires after the field has been marked as invalid.
32 * @param {Roo.form.FieldLabel} this
33 * @param {String} msg The validation message
38 * Fires after the field has been validated with no errors.
39 * @param {Roo.form.FieldLabel} this
45 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
52 invalidClass : 'text-danger fa fa-lg fa-exclamation-triangle',
53 validClass : 'text-success fa fa-lg fa-check',
56 getAutoCreate : function(){
76 initEvents: function()
78 Roo.bootstrap.Element.superclass.initEvents.call(this);
83 * Mark this field as valid
85 markValid : function(){
86 if(!this.el || this.preventMark){ // not rendered
90 this.el.removeClass([this.invalidClass, this.validClass]);
92 var feedback = this.el.select('.form-control-feedback', true).first();
95 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
98 if(this.disabled || this.allowBlank){
102 this.el.addClass(this.validClass);
104 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
106 var feedback = this.el.select('.form-control-feedback', true).first();
109 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
110 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
115 this.fireEvent('valid', this);
119 * Mark this field as invalid
120 * @param {String} msg The validation message
122 markInvalid : function(msg)
124 if(!this.el || this.preventMark){ // not rendered
128 this.el.removeClass([this.invalidClass, this.validClass]);
130 var feedback = this.el.select('.form-control-feedback', true).first();
133 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
136 if(this.disabled || this.allowBlank){
140 this.el.addClass(this.invalidClass);
142 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
144 var feedback = this.el.select('.form-control-feedback', true).first();
147 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
149 if(this.getValue().length || this.forceFeedback){
150 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
157 this.fireEvent('invalid', this, msg);