PDA

View Full Version : datefield validation override



lukemc
15 Apr 2011, 7:50 AM
First Post, Hey :)


I needed a datecolumn with some custom behaviour, specifically I needed to be able to enter in a date or and age in the same field.

So I tried having a datecolumn with the editor defined like this (note the validate override):


editor: {
xtype: 'datefield',
format: 'd/m/Y',
validate: function(){
if(!this.value.match(SOME_REGEX){
if(!this.value.match(SOME_REGEX){
return false;
}
}
return true;
}
}


Chrome debugger shows that the validate event and validate correctly however, when I try and put in an age, after hitting enter the field takes the value and tries to make a date out of it, rendering that guessed date back into the field and THEN validate is called.

The only documented before-validate event that I can find is
stripCharsRe that defaults to NULL.

Can anyone shed any light on this?