PDA

View Full Version : TimeField maxValue and minValue validation does not work



dianext
19 Dec 2013, 2:11 AM
Ext version tested:

Ext 3.3.3
Browser versions tested against:

Chrome 31
Description:

I set TimeField maxValue and minValue but it dose not work
Steps to reproduce the problem:

Timefield setting


{

fieldLabel:'Time',

xtype:'timefield',

minValue:'6:00 AM',

maxValue:'9:00 AM'

}


manual input 5:00 AM
The result that was expected:

time field show invalid-mark
The result that occurs instead:

time field does not show invalid-mark
Solution:


Ext.override(Ext.form.TimeField, {
/**
* fix maxValue & minValue validation not work bug
*/
getErrors: function(value) {
var errors = Ext.form.DateField.superclass.getErrors.apply(this, arguments);


value = this.formatDate(value || this.processValue(this.getRawValue()));
if (value.length < 1) { // if it's blank and textfield didn't flag it then it's valid
return errors;
}


var svalue = value;
value = this.parseDate(value);
if (!value) {
errors.push(String.format(this.invalidText, svalue, this.format));
return errors;
}


var time = value.getTime();


if (this.minValue && time < this.minValue.getTime()) {
errors.push(String.format(this.minText, this.formatDate(this.minValue)));
}


if (this.maxValue && time > this.maxValue.getTime()) {
errors.push(String.format(this.maxText, this.formatDate(this.maxValue)));
}


if (this.disabledDays) {
var day = value.getDay();


for (var i = 0; i < this.disabledDays.length; i++) {
if (day === this.disabledDays[i]) {
errors.push(this.disabledDaysText);
break;
}
}
}


var fvalue = this.formatDate(value);
if (this.disabledDatesRE && this.disabledDatesRE.test(fvalue)) {
errors.push(String.format(this.disabledDatesText, fvalue));
}


return errors;
}
});

Gary Schlosberg
11 Jan 2014, 8:46 AM
Thanks for the report and override. Can you please post a runnable test case which reproduces the issue? Feel free to use our Fiddle:
https://fiddle.sencha.com/#home

dianext
11 Jan 2014, 1:00 PM
Hi, Gray,

Please try this, https://fiddle.sencha.com/#fiddle/2a1

i (https://fiddle.sencha.com/#fiddle/2a1)f you input "5:00 AM" at first field(Ext 3.3 Original TImefiled), there is not display invalid msg.
the same input works on Fixed Timefield.