diff options
author | xue <> | 2006-01-19 02:54:27 +0000 |
---|---|---|
committer | xue <> | 2006-01-19 02:54:27 +0000 |
commit | 5d88ad05e5956071d5904662d133625f157ce230 (patch) | |
tree | 9788f5edddb40024256440208ae2f87eef14269b /framework/Web/UI/WebControls/TRegularExpressionValidator.php | |
parent | e4a486b62af0895fd690588129de1190ebf7bd12 (diff) |
Added documentation to validator controls.
Diffstat (limited to 'framework/Web/UI/WebControls/TRegularExpressionValidator.php')
-rw-r--r-- | framework/Web/UI/WebControls/TRegularExpressionValidator.php | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/framework/Web/UI/WebControls/TRegularExpressionValidator.php b/framework/Web/UI/WebControls/TRegularExpressionValidator.php index 9fe0f778..f20c2d16 100644 --- a/framework/Web/UI/WebControls/TRegularExpressionValidator.php +++ b/framework/Web/UI/WebControls/TRegularExpressionValidator.php @@ -21,7 +21,7 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator'); * TRegularExpressionValidator validates whether the value of an associated
* input component matches the pattern specified by a regular expression.
*
- * You can specify the regular expression by setting the <b>RegularExpression</b>
+ * You can specify the regular expression by setting the {@link setRegularExpression RegularExpression}
* property. Some commonly used regular expressions include:
* <pre>
* French Phone Number: (0( \d|\d ))?\d\d \d\d(\d \d| \d\d )\d\d
@@ -40,6 +40,9 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator'); * U.S. Social Security Number: \d{3}-\d{2}-\d{4}
* </pre>
*
+ * Note, the validation succeeds if the associated input control contains empty input.
+ * Use a {@link TRequiredFieldValidator} to ensure the input is not empty.
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
@@ -56,8 +59,7 @@ class TRegularExpressionValidator extends TBaseValidator }
/**
- * Sets the regular expression that determines the pattern used to validate a field.
- * @param string the regular expression
+ * @param string the regular expression that determines the pattern used to validate a field.
*/
public function setRegularExpression($value)
{
@@ -73,19 +75,18 @@ class TRegularExpressionValidator extends TBaseValidator */
public function evaluateIsValid()
{
- if(($control=$this->getValidationTarget())!==null)
- {
- if(($value=$this->getValidationValue($control))==='')
- return true;
- if(($expression=$this->getRegularExpression())!=='')
- return preg_match("/^$expression\$/",$value);
- else
- return true;
- }
+ if(($value=$this->getValidationValue($this->getValidationTarget()))==='')
+ return true;
+ if(($expression=$this->getRegularExpression())!=='')
+ return preg_match("/^$expression\$/",$value);
else
- throw new TInvalidDataValueException('regularexpressionvalidator_controltovalidate_invalid');
+ return true;
}
+ /**
+ * Returns an array of javascript validator options.
+ * @return array javascript validator options.
+ */
protected function getClientScriptOptions()
{
$options = parent::getClientScriptOptions();
|