首先重写textfield方法,添加maxLength属性
然后在用的地方添加maxLength属性
Ext.form.TextField.prototype.initValue = function()
{
if(this.value !== undefined){
this.setValue(this.value);
}else if(this.el.dom.value.length > 0){
this.setValue(this.el.dom.value);
}
this.el.dom.size = this.size;
if (!isNaN(this.maxLength) && (this.maxLength *1) > 0 && (this.maxLength != Number.MAX_VALUE)) {
this.el.dom.maxLength = this.maxLength *1;
}
};
然后在用的地方添加maxLength属性
{
xtype: 'textfield',
name: 'realname',
label: '<span style="color:#ff0000;float:none;">*</span>姓名',
labelWidth : '30%',
maxLength : 4,
placeHolder : '请输入姓名',
},