From fceb3741d3b0c1e00e81a4a24caf7d49a86896b4 Mon Sep 17 00:00:00 2001 From: xue <> Date: Wed, 22 Feb 2006 02:46:25 +0000 Subject: Updated some validators and relevant demos. --- .../Web/UI/WebControls/TEmailAddressValidator.php | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'framework/Web/UI/WebControls/TEmailAddressValidator.php') diff --git a/framework/Web/UI/WebControls/TEmailAddressValidator.php b/framework/Web/UI/WebControls/TEmailAddressValidator.php index b6ceff90..3534d1d0 100644 --- a/framework/Web/UI/WebControls/TEmailAddressValidator.php +++ b/framework/Web/UI/WebControls/TEmailAddressValidator.php @@ -19,8 +19,9 @@ Prado::using('System.Web.UI.WebControls.TRegularExpressionValidator'); * TEmailAddressValidator class * * TEmailAddressValidator validates whether the value of an associated - * input component is a valid email address. It will check MX record - * if checkdnsrr() is available in the installed PHP. + * input component is a valid email address. If {@link getCheckMXRecord CheckMXRecord} + * is true, it will check MX record for the email adress, provided + * checkdnsrr() is available in the installed PHP. * * @author Qiang Xue * @version $Revision: $ $Date: $ @@ -50,7 +51,7 @@ class TEmailAddressValidator extends TRegularExpressionValidator public function evaluateIsValid() { $valid=parent::evaluateIsValid(); - if($valid && function_exists('checkdnsrr')) + if($valid && $this->getCheckMXRecord() && function_exists('checkdnsrr')) { if(($value=$this->getValidationValue($this->getValidationTarget()))!=='') { @@ -65,6 +66,23 @@ class TEmailAddressValidator extends TRegularExpressionValidator } return $valid; } + + /** + * @return boolean whether to check MX record for the email address being validated. Defaults to true. + */ + public function getCheckMXRecord() + { + return $this->getViewState('CheckMXRecord',true); + } + + /** + * @param boolean whether to check MX record for the email address being validated. + * Note, if {@link checkdnsrr} is not available, this check will not be performed. + */ + public function setCheckMXRecord($value) + { + $this->setViewState('CheckMXRecord',TPropertyValue::ensureBoolean($value),true); + } } ?> \ No newline at end of file -- cgit v1.2.3