Roo/bootstrap/DateField.js
[roojs1] / Roo / bootstrap / DateField.js
index 9429015..9c25a53 100644 (file)
@@ -928,16 +928,72 @@ Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input,  {
         this.picker().remove();
     },
     
-    validate : function()
+    validateValue : function(value)
     {
-        if(this.disabled || this.validateValue(this.getRawValue())){
-            this.markValid();
+        if(this.getVisibilityEl().hasClass('hidden')){
             return true;
         }
         
-        this.markInvalid();
-        return false;
+        if(value.length < 1)  {
+            if(this.allowBlank){
+                return true;
+            }
+            return false;
+        }
+        
+        if(value.length < this.minLength){
+            return false;
+        }
+        if(value.length > this.maxLength){
+            return false;
+        }
+        if(this.vtype){
+            var vt = Roo.form.VTypes;
+            if(!vt[this.vtype](value, this)){
+                return false;
+            }
+        }
+        if(typeof this.validator == "function"){
+            var msg = this.validator(value);
+            if(msg !== true){
+                return false;
+            }
+        }
+        
+        if(this.regex && !this.regex.test(value)){
+            return false;
+        }
+        
+        if(typeof(this.parseDate(value)) == 'undefined'){
+            return false;
+        }
+        
+        if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
+            return false;
+        }      
+        
+        if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
+            return false;
+        } 
+        
+        
+        return true;
     },
+    
+    setVisible : function(visible)
+    {
+        if(!this.getEl()){
+            return;
+        }
+        
+        this.getEl().removeClass('hidden');
+        
+        if(visible){
+            return;
+        }
+        
+        this.getEl().addClass('hidden');
+    }
    
 });