I'm having the following problem: I want to validate a DateField so that it has a value between the minValue / maxValue range. (greater or equal, lower or equal)
The problem is that I think the framework takes the time in milliseconds.
I've tried using a custom vtype such as:
Ext.apply(Ext.form.VTypes,{
dates: function(val, field){
try{
if(this.disabled){
return true;
}
if(Ext.value(val,null,false)==null){
this.datesText = "This field is required.";
return this.allowBlank; //the text message won't be shown in case blank is allowed.
}
if(Ext.value(field.minValue,null,false)!=null){
if(Ext.util.Format.date(val,"Ymd")<Ext.util.Format.date(field.minValue,"Ymd")){
this.datesText = "The value is invalid.<br/>";
this.datesText = "it must be greater or equal than " + field.minValue;
return false;
}
}
if(Ext.value(field.maxValue,null,false)!=null){
if(Ext.util.Format.date(val,"Ymd")>Ext.util.Format.date(field.maxValue,"Ymd")){
this.datesText = "The value is invalid.<br/>";
this.datesText = "It must be lower or equal than " + field.maxValue;
return false;
}
}
return true;
}catch(e){
return false;
}
},
datesText: 'The value is invalid.', //error message
datesMask: / / //regexp to filter the characters allowed
});
Basically what it does is convert the values to a 'Ymd' format and then compare values as numbers.
If I debug this code, the validation goes okay, but for some reason I still get an error message. I believe the framework is trying to validate the field again after my validation.
Thank you!
Sebastián