停止extjs TextField接受空格和空格 [英] stop extjs TextField from accepting blanks and spaces

查看:231
本文介绍了停止extjs TextField接受空格和空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的文本框

siteNameField = new Ext.form.TextField({
id: 'siteNameField',
fieldLabel: 'Site Name',
maxLength: 50,
allowBlank: false,
anchor:'-15',
xtype:'textfield',
maskRe: /([a-zA-Z0-9\s]+)$/

});

正如你所看到的,它已经有一个空格的检查。但文本字段接受空格,我不想要。我想要没有空白的字段...除了'ONLY'空格之外的任何其他内容都是可以接受的。

As you can see it already has a check for blanks. But text field accepts space and I don't want that. I want no blank fields ... anything other than 'ONLY' spaces is acceptable .

这是FormPanel代码

Here is the FormPanel Code

voiceSiteCreateForm = new Ext.FormPanel({
    labelAlign: 'top',
    bodyStyle:'padding:5px',
    width: 600,        
    items: [{
        layout:'column',
        border:false,
        items:[{
            columnWidth:0.5,
            layout: 'form',
            border:false,
            //items: [siteNameField, siteNumberField,queueNameField,notifyFreqField,notifyStatusField]
            items: [siteNameField, siteNumberField]
        }]
    }],
buttons: [{
  text: 'Save and Close',
  handler: createSite
},{
  text: 'Cancel',
  handler: function(){
    // because of the global vars, we can only instantiate one window... so let's just hide it.
    siteCreateWindow.hide();
  }
}]
});

请帮助,

推荐答案

删除maskRe并使用正则表达式。例如:

Remove maskRe and use regex. Eg:

siteNameField = new Ext.form.TextField({
  id: 'siteNameField',
  fieldLabel: 'Site Name',
  maxLength: 50,
  allowBlank: false,
  anchor:'-15',
  xtype:'textfield',
  regex: /[a-zA-Z0-9]+/
});

这篇关于停止extjs TextField接受空格和空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆