gpt4 book ai didi

javascript - Extjs - formPanel 上的 isValid()

转载 作者:行者123 更新时间:2023-11-30 17:27:46 24 4
gpt4 key购买 nike

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

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() 任何人都可以帮助我吗?

最佳答案

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

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

关于javascript - Extjs - formPanel 上的 isValid(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23876006/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com