简体   繁体   English

提交表单时不检查ext js中的必填字段

[英]Form submitting without checking mandatory field in ext js

I added some fields in an ext js form with required 'itemCls'. 我在ext js表单中添加了一些带有必需的“ itemCls”的字段。 But the form submitting without checking (mandatory fields) the fields null or not. 但是表单提交时不检查(必填字段)这些字段是否为空。

My code is given below, 我的代码如下

  xtype: 'form', id: 'form', bodyStyle: 'overflow : auto; height: 337px;', items: [{ xtype: 'fieldset', items: [{ xtype: 'combo', id: 'adr', anchor: '98%', listWidth: 300, itemCls: 'required', editable: false, store: store, displayField: 'NAM', valueField: 'ID', triggerAction: 'all', mode: 'local' }, { xtype: 'datefield', id: 'date', name: 'date', itemCls: 'required', readOnly: false, }, { xtype: 'textfield', id: 'name', itemCls: 'required', anchor: '98%', fieldLabel: 'name', name: 'name' }] }, { xtype: 'button', text: 'Save', handler: function(btn, evt) { Ext.getCmp('form').getForm().submit(); } }] 

Any help is must appreciated.. 任何帮助都必须感谢。

You have to add monitorValid : true to form . 您必须将monitorValid :true添加到form中 Then you can use listener clientvalidation on form , for exmaple, to disable submit button 然后,您可以在表单上使用监听器clientvalidation (例如)来禁用“提交”按钮

listeners: {
  clientvalidation : function(form, valid) {
    Ext.getCmp('button-save').setDisabled(!valid);
  }
}

After that client validation will work as expected. 之后,客户端验证将按预期进行。 NOTE: button-save is id which should be on Save button. 注意: button-saveid ,应该在Save按钮上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM