0

我是 ExtJS 的新手。考虑下面的 Textfield 声明:

{
    xtype: 'textfield',
    id:'lcfirstname',
    name: 'lcfirstname',
    maxLength: 100,
    regex: '/^\s*[a-zA-Z0-9-_]*$/'
}

我能够根据模式编写一个模式,可以在文本字段中输入什么和所有内容。但我需要在文本字段中编写模式,以便文本字段不应该采用那些模式
(即不是像 EXT JS 中那样的正则表达式?)。该模式可以包含所有特殊符号。

这里需要帮助!!

4

2 回答 2

0

有两种选择可以解决这个问题:

  • 你可以使用正则表达式:
{
    xtype: 'textfield',
    id:'lcfirstname',
    name: 'lcfirstname',
    maxLength: 100,
    regex: /^(?!.*[a-zA-Z0-9-_])/
}
  • 或者您可以编写自定义验证器:
{
    xtype: 'textfield',
    id:'lcfirstname',
    name: 'lcfirstname',
    maxLength: 100, 
    invalidChars: '[a-z]',
    validator: function(value) {
        var me = this;            
        return new RegExp('^(?!.*' + me.invalidChars + ')' ).test(value);
    }    
}
于 2013-09-12T11:43:39.243 回答
0

前 (3) 三个字母字符被选中,然后其他最后一个字符不包括

正则表达式:

/^[a-zA-Z0-9]{3,}(?!.*[~`@#$%^={}*:;,.<>+?½£|])/ 
于 2021-03-19T07:34:35.273 回答