Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,555
    Vote Rating
    55
    Animal will become famous soon enough

      0  

    Default [UNKNOWN][3.*,2.*]DateField.validateValue calls superclass's validateValue too soon

    Check the examples/form/adv-vtypes example. With the latest markInvalid fix defining msgDisplay as ''!

    If you type in an invalid date, it performs TextField's validateValue first, before applying date validation.

    This causes an incorrect error message to be displayed.

    DateField.validateValue needs to be

    Code:
    Ext.override(Ext.form.DateField, {
        validateValue : function(value){
            value = this.formatDate(value);
            if(!Ext.form.DateField.superclass.validateValue.call(this, value)){
                return false;
            }
            if(value.length < 1){ // if it's blank and textfield didn't flag it then it's valid
                 return true;
            }
            var svalue = value;
            value = this.parseDate(value);
            if(!value){
                this.markInvalid(String.format(this.invalidText, svalue, this.format));
                return false;
            }
            var time = value.getTime();
            if(this.minValue && time < this.minValue.getTime()){
                this.markInvalid(String.format(this.minText, this.formatDate(this.minValue)));
                return false;
            }
            if(this.maxValue && time > this.maxValue.getTime()){
                this.markInvalid(String.format(this.maxText, this.formatDate(this.maxValue)));
                return false;
            }
            if(this.disabledDays){
                var day = value.getDay();
                for(var i = 0; i < this.disabledDays.length; i++) {
                    if(day === this.disabledDays[i]){
                        this.markInvalid(this.disabledDaysText);
                        return false;
                    }
                }
            }
            var fvalue = this.formatDate(value);
            if(this.disabledDatesRE && this.disabledDatesRE.test(fvalue)){
                this.markInvalid(String.format(this.disabledDatesText, fvalue));
                return false;
            }
    
    //      Perform TextField processing only after specialized Date validation
            if(!Ext.form.DateField.superclass.validateValue.call(this, value)){
                return false;
            }
            return true;
        }
    });

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    105
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default

    That would kill the allowBlank check. I suggest:
    Code:
    Ext.override(Ext.form.DateField, {
        validateValue : function(value){
            value = this.formatDate(value);
            /*if(!Ext.form.DateField.superclass.validateValue.call(this, value)){
                return false;
            }
            if(value.length < 1){ // if it's blank and textfield didn't flag it then it's valid
                 return true;
            }*/
            if(value){ // The textfield will check allowBlank
                var svalue = value;
                value = this.parseDate(value);
                if(!value){
                    this.markInvalid(String.format(this.invalidText, svalue, this.format));
                    return false;
                }
                var time = value.getTime();
                if(this.minValue && time < this.minValue.getTime()){
                    this.markInvalid(String.format(this.minText, this.formatDate(this.minValue)));
                    return false;
                }
                if(this.maxValue && time > this.maxValue.getTime()){
                    this.markInvalid(String.format(this.maxText, this.formatDate(this.maxValue)));
                    return false;
                }
                if(this.disabledDays){
                    var day = value.getDay();
                    for(var i = 0; i < this.disabledDays.length; i++) {
                        if(day === this.disabledDays[i]){
                            this.markInvalid(this.disabledDaysText);
                            return false;
                        }
                    }
                }
                var fvalue = this.formatDate(value);
                if(this.disabledDatesRE && this.disabledDatesRE.test(fvalue)){
                    this.markInvalid(String.format(this.disabledDatesText, fvalue));
                    return false;
                }
            }
            // Perform TextField processing only after specialized Date validation
            return Ext.form.DateField.superclass.validateValue.call(this, value);
        }
    });
    (You can also save some bytes on the last few lines)

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,555
    Vote Rating
    55
    Animal will become famous soon enough

      0  

    Default

    Yes. Well spotted.

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,555
    Vote Rating
    55
    Animal will become famous soon enough

      0  

    Default

    This one is still open.

    examples/form/adv-vtypes.html

    Type an invalid date into one of the DateFields, and it displays the message

    {0} is not a valid date - it must be in the format {1}

Thread Participants: 1