如果用户在输入密码时打开大写锁定,我想添加一条消息.到目前为止,这是我尝试过的.
{
xtype:'textfield',
itemId: 'field_password_login',
fieldLabel: 'Password',
inputType: 'password',
allowBlank: false,
listeners:
{
keypress: function(tf, e)
{
if (e.getKey() != 13 && e.getKey() != 10 && e.getKey() != 127)
{
if ((!e.shiftKey && (e.getKey() >= 65 && e.getKey() <= 90)) || ((e.getKey() >= 97 && e.getKey() <= 122) && e.shiftKey))
{
Ext.getCmp("app_idCAPSIndicator").setText("CAPS LOCK is ON");
Ext.getDom("app_idCAPSIndicator").style.color = "navy";
}
else
{
Ext.getCmp("app_idCAPSIndicator").setText("");
}
}
if (e.getKey() == 13)
{
Ext.Msg.alert("Enter Pressed");
}
}
}
},
{
xtype: 'label',
fieldLabel: '',
labelWidth: 90,
labelAlign: 'left',
labelSeperator: '',
id: 'app_idCAPSIndicator'
}
但这行不通.我没有错误消息知道发生了什么.我在这里做错了什么?
解决方法:
添加enableKeyEvents:true,如果为true,则为HTML输入字段启用键事件的代理
{
xtype:'textfield',
itemId: 'field_password_login',
fieldLabel: 'Password',
inputType: 'password',
allowBlank: false,
enableKeyEvents: true,
listeners:
{
keypress: function(tf, e)
{
if (e.getKey() != 13 && e.getKey() != 10 && e.getKey() != 127)
{
if ((!e.shiftKey && (e.getKey() >= 65 && e.getKey() <= 90)) || ((e.getKey() >= 97 && e.getKey() <= 122) && e.shiftKey))
{
Ext.getCmp("app_idCAPSIndicator").setText("CAPS LOCK is ON");
Ext.getDom("app_idCAPSIndicator").style.color = "navy";
}
else
{
Ext.getCmp("app_idCAPSIndicator").setText("");
}
}
if (e.getKey() == 13)
{
Ext.Msg.alert("Enter Pressed");
}
}
}
},
原文地址:https://codeday.me/bug/20191211/2106480.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。