【问题标题】:Extjs - isValid() on formPanelExtjs - formPanel 上的 isValid()
【发布时间】:2014-05-27 06:58:42
【问题描述】:

将此表单面板作为登录页面:

Ext.create('Ext.container.Viewport', {        
 renderTo: Ext.getBody(),        
 layout:{           
 type:'fit'         
},        
 items: [           
 {         
   xtype: 'form',           
 id: 'loginForm',           
 border: false,           
 layout: {             
 type: 'vbox',              
align: 'center',              
pack: 'center'          
},       
height : Ext.getBody().getViewSize().height,       
width : Ext.getBody().getViewSize().width,      
defaultType : 'textfield',      
listeners: {               
 afterRender: function(thisForm, options){               
 this.keyNav = Ext.create('Ext.util.KeyNav', this.el, {                
enter: function(){if(loginForm.getForm().isValid())                      
 login(loginForm);              
  },                
scope: this                    
});                
}             
},...........

在填写详细信息后,我正在尝试配置按 Enter 进行提交。这一行:

enter: function(){if(loginForm.getForm().isValid())

但是,如果我将其替换为以下内容,则无法正常工作:

enter: function(){Ext.getCmp('firstField').getValue().length && Ext.getCmp('secondField').getValue().length

它工作得很好。但我想使用 isValid() 有人可以帮我吗?

【问题讨论】:

    标签: javascript forms extjs extjs4 extjs-form


    【解决方案1】:

    loginForm 未定义(至少在问题的代码中未定义)。通过 id 获取:

     if(Ext.getCmp('loginForm').getForm().isValid()) 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-22
      • 1970-01-01
      • 1970-01-01
      • 2011-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多