EXT dateRange

VTYPES:

Ext.apply(Ext.form.VTypes, {

                daterange: function (val, field) {

                    var date = field.parseDate(val);



                    if (!date) {

                        return;

                    }

                    if (field.startDateField && (!this.dateRangeMax || (date.getTime() != this.dateRangeMax.getTime()))) {

                        var start = Ext.getCmp(field.startDateField);

                        start.setMaxValue(date);

                        start.validate();

                        this.dateRangeMax = date;

                    }

                    else if (field.endDateField && (!this.dateRangeMin || (date.getTime() != this.dateRangeMin.getTime()))) {

                        var end = Ext.getCmp(field.endDateField);

                        end.setMinValue(date);

                        end.validate();

                        this.dateRangeMin = date;

                    }

                    return true;

                },

                daterangeText: "开始日期和结束日期不匹配"

            });

 

 

日期控件:

{

                        id: 'personstartdate',

                        xtype: 'datefield',

                        width: 190,

                        maxValue: new Date(),

                        margins: '0 0 0 6',

                        labelWidth: 60,

                        fieldLabel: '从',

                        format: 'Y-m-d',

                        endDateField: 'personenddate',

                        vtype: 'daterange'



                    }, {

                        id: 'personenddate',

                        xtype: 'datefield',

                        width: 150,

                        maxValue: new Date(),

                        margins: '0 0 0 6',

                        labelWidth: 20,

                        fieldLabel: '至',

                        format: 'Y-m-d',

                        startDateField: 'personstartdate',

                        vtype: 'daterange'

                    }

 

你可能感兴趣的:(Date)