stop extjs TextField from accepting blanks and spaces
This is my textfield
siteNameField = new Ext.form.TextField({
id: 'siteNameField',
fieldLabel: 'Site Name',
maxLength: 50,
allowBlank: false,
开发者_Go百科anchor:'-15',
xtype:'textfield',
maskRe: /([a-zA-Z0-9\s]+)$/
});
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 .
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();
}
}]
});
Please help,
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]+/
});
精彩评论