1 // checks custom validators first
  2 // from http://extjs.com/forum/showthread.php?p=191182
  3 
  4 Ext.override(Ext.form.TextField, {
  5     validateValue : function(value){
  6         if(typeof this.validator == "function"){
  7             var msg = this.validator(value);
  8             if(msg !== true){
  9                 this.markInvalid(msg);
 10                 return false;
 11             }
 12         }
 13         if(this.vtype){
 14             var vt = Ext.form.VTypes;
 15             if(!vt[this.vtype](value, this)){
 16                 this.markInvalid(this.vtypeText || vt[this.vtype +'Text']);
 17                 return false;
 18             }
 19         }
 20         if(this.regex && !this.regex.test(value)){
 21             this.markInvalid(this.regexText);
 22             return false;
 23         }
 24         if(value.length < 1 || value === this.emptyText){ // if it's blank
 25              if(this.allowBlank){
 26                  this.clearInvalid();
 27                  return true;
 28              }else{
 29                  this.markInvalid(this.blankText);
 30                  return false;
 31              }
 32         }
 33         if(value.length < this.minLength){
 34             this.markInvalid(String.format(this.minLengthText, this.minLength));
 35             return false;
 36         }
 37         if(value.length > this.maxLength){
 38             this.markInvalid(String.format(this.maxLengthText, this.maxLength));
 39             return false;
 40         }
 41         return true;
 42     }
 43 });