Extjs控制文本输入字数,超出设定输入字数后弹框提示用户,怎么做???
1个回答
2017-04-21
展开全部
如果是textfield设置maxlength,校验如果超出长度会提示信息;
Ext.create('Ext.form.Panel', {
title: 'Contact Info',
width: 300,
bodyPadding: 10,
renderTo: Ext.getBody(),
items: [{
xtype: 'textfield',
name: 'name',
fieldLabel: 'Name',
maxLength:5,
allowBlank: false // requires a non-empty value
}, {
xtype: 'textfield',
name: 'email',
fieldLabel: 'Email Address',
vtype: 'email' // requires value to be a valid email address format
}]
});
添加事件
xtype: 'textfield',
name: 'name',
enableKeyEvents:true,
fieldLabel: 'Name',
allowBlank: false, // requires a non-empty value
listeners: {
keypress: function(o,e){
//TO-DO o.value.length...
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询