必填项的label后面加星号

必填项的label后面加星号

Ext.form.TextField.override({  

                initComponent: Ext.form.TextField.prototype.initComponent.createInterceptor(function(){  

                    if (this.allowBlank === false && this.fieldLabel) {  

                        this.fieldLabel += '<font color=red>*</font>';  

                    }  

                })  

            });  

所有的输入项如果配置了allowBlack 为false,它的label后面就都会有红星号了,方便日后统一修改。

这段代码加在appbase.js的最后,label里不需要再写 <font color=\'red\'>*</font>
原文地址:https://www.cnblogs.com/meetrice/p/2006573.html