简体   繁体   English

ExtJS通过显示阻止对表单字段的验证:无

[英]ExtJS Prevent validation for form fields with display: none

I want to prevent validation for form fields with display: none . 我想防止对带有display: none表单字段进行验证。

For example fields with ipv6 set to display: none , I dont want to check this fields with form isValid() method. 例如,将ipv6设置为display: none字段display: none ,我不想使用isValid()方法检查此字段。

 var form = new Ext.form.FormPanel({ frame: true, bodyStyle: 'padding:5px 5px 0;', items: [{ xtype: 'radiogroup', id: 'ip_type', fieldLabel: 'IPType', columns: 2, items: [{ boxLabel: 'IPv4', name: 'ip_type', inputValue: 'ipv4', checked: true }, { boxLabel: 'IPv6', name: 'ip_type', inputValue: 'ipv6' }], listeners: { 'change': function(radioGroup, checkedRadio) { if (checkedRadio.inputValue == 'ipv4') { Ext.fly('ip').setStyle({ display: 'block' }); Ext.fly('ipv6').setStyle({ display: 'none' }); Ext.getCmp('ip').enable(); Ext.getCmp('ipv6').disable(); } else { Ext.fly('ip').setStyle({ display: 'none' }); Ext.fly('ipv6').setStyle({ display: 'block' }) Ext.getCmp('ip').disable(); Ext.getCmp('ipv6').enable(); } } } }, { id: 'ip', layout: 'column', border: false, hideBorders: true, items: [{ layout: 'form', items: [{ fieldLabel: 'IP', xtype: 'ipv4field', name: 'ip', allowBlank: false, regex: ipv4_reg, }] }, { html: '/' }, { xtype: 'numberfield', name: 'netmask', allowBlank: false, allowDecimals: false, minValue: 0, maxValue: 32, width: 70 }] }, { id: 'ipv6', layout: 'column', border: false, hideBorders: true, items: [{ layout: 'form', items: [{ fieldLabel: 'IP', xtype: 'textfield', name: 'ipv6', allowBlank: false, regex: ipv6_reg, }] }, { html: '/' }, { xtype: 'numberfield', name: 'netmaskipv6', //allowBlank: false, allowDecimals: false, minValue: 0, maxValue: 128, width: 70 }] }] }); 

To avoid validation of radio you can use Ext.form.Radio.disabled or if you want to send field value during form submit you can set Ext.form.Radio.validationEvent to false . 为了避免对单选进行验证,可以使用Ext.form.Radio.disabled如果要在提交表单期间发送字段值,可以将Ext.form.Radio.validationEvent设置为false

Also its better to use ExtJS Ext.form.Radio.hidden property instead of css display . 同样,最好使用ExtJS Ext.form.Radio.hidden属性代替CSS display

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

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