可用: Ext.form.Panel:EXTJS驗證面板中窗口
this.myForm = Ext.create("Ext.form.Panel", {
items : [{
xtype : 'textfield',
name : 'val1',
fieldLabel : 'val1',
allowBlank: false,
validator : function(value) { // validate val1
if (!(/^[a-zA-Z]+[\w]*$/.test(value)))
return "val1 is not valid";
return true;
}
}, {
xtype : 'textfield',
name : 'code',
fieldLabel : 'val2',
allowBlank: false,
validator : function(value) { // validate val2
if (!(/^[a-zA-Z]+[\w]*$/.test(value)))
return "val2 is not valid";
return true;
}
}]
});
然後將其發送到窗口:
Ext.window.Window:
this.someWindow = Ext.create("Ext.window.Window", { items : [me.myForm, me.anotherPanel], title : 'test', closeAction : 'hide', buttons : [{ text : 'Save', handler : function() { // some actions }
如何驗證val1和val2 myForm從someWindow on action:save?
是的,最佳答案,謝謝! – user2352679