gpt4 book ai didi

javascript - ExtJs 更改创建输入的 maskRe

转载 作者:行者123 更新时间:2023-11-28 06:33:31 26 4
gpt4 key购买 nike

是否可以更改创建的输入字段的 maskRe?如果是,怎么办?

{
xtype: 'textfield',
maskRe: /\d{0,5}/i
}

最佳答案

是的,而且您已经在这样做了。

但是 maskRe 仅应用于新 Angular 色。来自文档:

An input mask regular expression that will be used to filter keystrokes (character being typed) that do not match. Note: It does not filter characters already in the input.

这意味着maskRe不能用于一定的长度要求;您可以使用 maxLength 来实现这一点。

如果您想即时更改它,则没有记录的方法可以执行此操作。在 6.0.1 中,根据代码,使用 textbox.maskRe = newValue 就足够了,因为 filterKeys function看起来如下:

filterKeys : function(e){
/*
* Current only FF will fire keypress events for special keys.
*
* On European keyboards, the right alt key, Alt Gr, is used to type certain special characters.
* JS detects a keypress of this as ctrlKey & altKey. As such, we check that alt isn't pressed
* so we can still process these special characters.
*/
if ((e.ctrlKey && !e.altKey) || e.isSpecialKey()) {
return;
}
var charCode = String.fromCharCode(e.getCharCode());
if (!this.maskRe.test(charCode)) {
e.stopEvent();
}
}

关于javascript - ExtJs 更改创建输入的 maskRe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34490504/

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