首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

最小长度与最大长度印证

2012-11-25 
最小长度与最大长度验证//取值范围(选择数字时显示)layout : tableform,border : false,id : customfie

最小长度与最大长度验证
            //取值范围(选择数字时显示)
            layout : 'tableform',
            border : false,
            id : 'customfields_min_max_length_id',
            hidden : true,
            items : [{//最小长度(MIN_LENGTH)
                xtype : 'numberfield',
                fieldLabel : '取值范围',
                // name : 'customfields_min_length',
                name : 'MIN_LENGTH',
                id : 'customfields_min_length_id',
                //readOnly : (customFields_id != null && customFields_id != "") ? true : false,
                style : 'background: url(Resources/images/pen.gif) no-repeat 3px center;padding-left:15px;',
                maxLength : 5,
                maxLengthText : '最小长度不能超过5位',
                width : 200
            }, {
                xtype : 'label',
                text : '~',
                style : 'margin-left:30px;'
            }, {
                //最大长度(MAX_LENGTH)
                xtype : 'numberfield',
                labelSeparator : "",
                name : 'MAX_LENGTH',
                id : 'customfields_max_length_id',
                style : 'background: url(Resources/images/pen.gif) no-repeat 3px center;padding-left:15px;margin-left:-30px',
                validator : function() {
                    if (Ext.getCmp('customfields_min_length_id').getValue() && Ext.getCmp('customfields_max_length_id').getValue()) {
                        var max = Ext.getCmp('customfields_max_length_id').getValue();
                        var min = Ext.getCmp('customfields_min_length_id').getValue();
                        if (min > max) {
                            Ext.getCmp('customfields_max_length_id').invalidText = "最大长度不能小于最小长度";
                            return false;
                        } else {
                            Ext.getCmp('customfields_max_length_id').clearInvalid();
                            return true;
                        }
                    }
                    return true;
                },
                maxLength : 5,
                maxLengthText : '最大长度不能超过5位',
                width : 200
            }

热点排行