gpt4 book ai didi

javascript - 如何在 Ext.Message.Box 中使用 keydown 事件

转载 作者:行者123 更新时间:2023-11-30 08:28:07 26 4
gpt4 key购买 nike

我想添加当我按下超过 250 个字符时触发的 keydown 事件。这是代码,

var c = Ext.MessageBox.show({
title: "Version Remarks",
id:'test',
inputType: "textareafield",
msg:"Please Enter Version Remarks: (Only 250 Character)",
width: 375,
buttons: Ext.MessageBox.OKCANCEL,
multiline: true,
label: Ext.MessageBox.label,
fn: b,
icon: Ext.MessageBox.INFO,
modal: true,
closable: false,
allowBlank: false,

});

c.textArea.on('change', function (e, text, o) {

if (text.length > 250) {
c.msgButtons.ok.setDisabled(true);
//c.label.setText("This is the label");
alert("You are not able to enter more than 250 Character.!!")
} else {
c.msgButtons.ok.setDisabled(false);
}
}

当我按下 251 个字符时,会显示弹出窗口并允许我输入字符,但现在我想使用 onkeydown 事件,该事件不允许用户输入超过 250 个字符的任何字符。

最佳答案

使用文本框的maxLength 配置并调用setMaxLength将其设置为 250 个字符。
来自 sencha 文档。

The maximum number of permitted input characters.

所以你的代码应该是这样的:

var c = Ext.MessageBox.show({
// your config
});
c.textArea.setMaxLength(250);

关于javascript - 如何在 Ext.Message.Box 中使用 keydown 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42020367/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com