我已经确认在 extjs 4.1 中没有文本字段的粘贴事件。但我不希望用户能够粘贴到这个文本字段中。还有哪些其他选项不允许用户在文本字段中粘贴任何值。请注意,文本字段只允许数值,不允许字符/特殊字符或字母。以下是我目前拥有的代码片段。
{
xtype:"textfield",
fieldLabel: 'Debit Account',
name:'debitAccount',
id : 'debitacct',
enableKeyEvents:true,
maskRe: /[0-9]/,
allowBlank: false,
allowNegative: false,
maxLength: 9,
enforceMaxLength:true,
listeners : {
specialkey : function(field, e) {
filterBackspaceKey(e);
}
}
}
感谢任何帮助。
最佳答案
在我看到链接@Sencha 之后,解决方案很简单。代码如下。
{
xtype:"textfield",
fieldLabel: 'Debit Account',
name:'debitAccount',
id : 'debitacct',
enableKeyEvents:true,
maskRe: /[0-9]/,
allowBlank: false,
allowNegative: false,
maxLength: 9,
enforceMaxLength:true,
listeners : {
specialkey : function(field, e) {
filterBackspaceKey(e);
},
paste: {
element: 'inputEl',
fn: function(event, inputEl) {
if(event.type == "paste"){
event.preventDefault();
return false;
}
}
}
}
}
引用来自 Sencha 的链接:http://www.sencha.com/forum/showthread.php?175253-Paste-event
关于javascript - Extjs 4.1 - 禁用文本字段的粘贴事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20854574/