停止extjs TextField接受空格和空格

时间:2011-06-29 08:01:58

标签: extjs

这是我的文本域

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'空格之外的任何东西都是可以接受的。

这是FormPanel代码

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();
  }
}]
});

请帮忙,

1 个答案:

答案 0 :(得分:9)

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

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