diff options
author | wei <> | 2006-09-01 01:07:51 +0000 |
---|---|---|
committer | wei <> | 2006-09-01 01:07:51 +0000 |
commit | 769856093ded9e4aae341a7d79b7f1441e7d5478 (patch) | |
tree | ba3e04abf5f73deed023bab7ec95b9b245dfcb22 /framework/Web/Javascripts | |
parent | 47a3cb88e7ed7f2a87bbf024dff3416fc6cd8002 (diff) |
Add TActiveCustomValidator
Diffstat (limited to 'framework/Web/Javascripts')
-rw-r--r-- | framework/Web/Javascripts/js/compressed/validator.js | 7 | ||||
-rw-r--r-- | framework/Web/Javascripts/js/debug/validator.js | 39 | ||||
-rw-r--r-- | framework/Web/Javascripts/prado/activecontrols3.js | 2 | ||||
-rw-r--r-- | framework/Web/Javascripts/prado/validation3.js | 42 |
4 files changed, 88 insertions, 2 deletions
diff --git a/framework/Web/Javascripts/js/compressed/validator.js b/framework/Web/Javascripts/js/compressed/validator.js index 037abfeb..79b532e6 100644 --- a/framework/Web/Javascripts/js/compressed/validator.js +++ b/framework/Web/Javascripts/js/compressed/validator.js @@ -180,7 +180,12 @@ return true;switch(this.options.Operator) {case"NotEqual":return(op1!=op2);case"GreaterThan":return(op1>op2);case"GreaterThanEqual":return(op1>=op2);case"LessThan":return(op1<op2);case"LessThanEqual":return(op1<=op2);default:return(op1==op2);}}});Prado.WebUI.TCustomValidator=Class.extend(Prado.WebUI.TBaseValidator,{evaluateIsValid:function() {var value=this.getValidationValue();var clientFunction=this.options.ClientValidationFunction;if(typeof(clientFunction)=="string"&&clientFunction.length>0) {validate=clientFunction.toFunction();return validate(this,value);} -return true;}});Prado.WebUI.TRangeValidator=Class.extend(Prado.WebUI.TBaseValidator,{evaluateIsValid:function() +return true;}});Prado.WebUI.TActiveCustomValidator=Class.extend(Prado.WebUI.TBaseValidator,{validatingValue:null,requestDispatched:false,evaluateIsValid:function() +{value=this.getValidationValue();if(!this.requestDispatched&&value!=this.validatingValue) +{this.validatingValue=value;request=new Prado.CallbackRequest(this.options.EventTarget,this.options);request.setParameter(value);request.setCausesValidation(false);request.options.onSuccess=this.callbackOnSuccess.bind(this);request.options.onFailure=this.callbackOnFailure.bind(this);request.dispatch();this.requestDispatched=true;return false;} +return this.isValid;},callbackOnSuccess:function(request,data) +{this.isValid=data;this.requestDispatched=false;Prado.Validation.validate(this.options.FormID,this.group,null);},callbackOnFailure:function(request,data) +{this.requestDispatched=false;}});Prado.WebUI.TRangeValidator=Class.extend(Prado.WebUI.TBaseValidator,{evaluateIsValid:function() {var value=this.getValidationValue();if(value.length<=0) return true;if(typeof(this.options.DataType)=="undefined") this.options.DataType="String";if(this.options.DataType!="StringLength") diff --git a/framework/Web/Javascripts/js/debug/validator.js b/framework/Web/Javascripts/js/debug/validator.js index ec57e876..72d9a01d 100644 --- a/framework/Web/Javascripts/js/debug/validator.js +++ b/framework/Web/Javascripts/js/debug/validator.js @@ -1100,6 +1100,45 @@ Prado.WebUI.TCustomValidator = Class.extend(Prado.WebUI.TBaseValidator, }
});
+Prado.WebUI.TActiveCustomValidator = Class.extend(Prado.WebUI.TBaseValidator,
+{
+ validatingValue : null,
+ requestDispatched : false,
+
+ /**
+ * Calls custom validation function.
+ */
+ evaluateIsValid : function()
+ {
+ value = this.getValidationValue();
+ if(!this.requestDispatched && value != this.validatingValue)
+ {
+ this.validatingValue = value;
+ request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
+ request.setParameter(value);
+ request.setCausesValidation(false);
+ request.options.onSuccess = this.callbackOnSuccess.bind(this);
+ request.options.onFailure = this.callbackOnFailure.bind(this);
+ request.dispatch();
+ this.requestDispatched = true;
+ return false;
+ }
+ return this.isValid;
+ },
+
+ callbackOnSuccess : function(request, data)
+ {
+ this.isValid = data;
+ this.requestDispatched = false;
+ Prado.Validation.validate(this.options.FormID, this.group,null);
+ },
+
+ callbackOnFailure : function(request, data)
+ {
+ this.requestDispatched = false;
+ }
+});
+
/**
* TRangeValidator tests whether an input value is within a specified range.
*
diff --git a/framework/Web/Javascripts/prado/activecontrols3.js b/framework/Web/Javascripts/prado/activecontrols3.js index e5be1d49..01d8a41e 100644 --- a/framework/Web/Javascripts/prado/activecontrols3.js +++ b/framework/Web/Javascripts/prado/activecontrols3.js @@ -91,7 +91,7 @@ Prado.WebUI.TAutoComplete = Class.extend(Prado.WebUI.TAutoComplete, {
if(!this.active)
{
- request = new Prado.CallbackRequest(options.EventTarget, options);
+ request = new Prado.CallbackRequest(this.options.EventTarget, options);
request.dispatch();
Event.stop(event);
}
diff --git a/framework/Web/Javascripts/prado/validation3.js b/framework/Web/Javascripts/prado/validation3.js index 8df3864c..46db6381 100644 --- a/framework/Web/Javascripts/prado/validation3.js +++ b/framework/Web/Javascripts/prado/validation3.js @@ -1101,6 +1101,48 @@ Prado.WebUI.TCustomValidator = Class.extend(Prado.WebUI.TBaseValidator, });
/**
+ * Uses callback request to perform validation.
+ */
+Prado.WebUI.TActiveCustomValidator = Class.extend(Prado.WebUI.TBaseValidator,
+{
+ validatingValue : null,
+ requestDispatched : false,
+
+ /**
+ * Calls custom validation function.
+ */
+ evaluateIsValid : function()
+ {
+ value = this.getValidationValue();
+ if(!this.requestDispatched && value != this.validatingValue)
+ {
+ this.validatingValue = value;
+ request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
+ request.setParameter(value);
+ request.setCausesValidation(false);
+ request.options.onSuccess = this.callbackOnSuccess.bind(this);
+ request.options.onFailure = this.callbackOnFailure.bind(this);
+ request.dispatch();
+ this.requestDispatched = true;
+ return false;
+ }
+ return this.isValid;
+ },
+
+ callbackOnSuccess : function(request, data)
+ {
+ this.isValid = data;
+ this.requestDispatched = false;
+ Prado.Validation.validate(this.options.FormID, this.group,null);
+ },
+
+ callbackOnFailure : function(request, data)
+ {
+ this.requestDispatched = false;
+ }
+});
+
+/**
* TRangeValidator tests whether an input value is within a specified range.
*
* TRangeValidator uses three key properties to perform its validation.
|