From 6c0154fb4e292ad22667e618f598a37cc5f9d524 Mon Sep 17 00:00:00 2001 From: xue <> Date: Thu, 15 Jun 2006 18:18:47 +0000 Subject: Merge from 3.0 branch till 1166. --- framework/Web/UI/WebControls/TBaseValidator.php | 38 ++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'framework/Web/UI/WebControls/TBaseValidator.php') diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php index 3fe9ee03..1194089e 100644 --- a/framework/Web/UI/WebControls/TBaseValidator.php +++ b/framework/Web/UI/WebControls/TBaseValidator.php @@ -473,10 +473,22 @@ abstract class TBaseValidator extends TLabel implements IValidator */ public function validate() { + $this->onValidate(); $this->setIsValid(true); $control=$this->getValidationTarget(); if($control && $this->getVisible(true) && $this->getEnabled()) - $this->setIsValid($this->evaluateIsValid()); + { + if($this->evaluateIsValid()) + { + $this->setIsValid(true); + $this->onSuccess(); + } + else + { + $this->setIsValid(false); + $this->onError(); + } + } return $this->getIsValid(); } @@ -503,6 +515,30 @@ abstract class TBaseValidator extends TLabel implements IValidator */ abstract protected function evaluateIsValid(); + /** + * This event is raised when the validator succeeds in validation. + */ + public function onSuccess() + { + $this->raiseEvent('OnSuccess',$this,null); + } + + /** + * This event is raised when the validator fails in validation. + */ + public function onError() + { + $this->raiseEvent('OnError',$this,null); + } + + /** + * This event is raised right before the validator starts to perform validation. + */ + public function onValidate() + { + $this->raiseEvent('OnValidate',$this,null); + } + /** * Renders the validator control. * @param THtmlWriter writer for the rendering purpose -- cgit v1.2.3