From 4baf17880e3c83b6900794459d2ebb9adf379aa3 Mon Sep 17 00:00:00 2001 From: "haertl.mike" <> Date: Wed, 29 Oct 2008 19:47:02 +0000 Subject: Fixed issue #13 (trac #813) --- HISTORY | 1 + .../source/prado/validator/validation3.js | 9 +++++---- .../UI/WebControls/TRegularExpressionValidator.php | 20 +++++++++++++++++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/HISTORY b/HISTORY index 46e39efc..38e46cb5 100644 --- a/HISTORY +++ b/HISTORY @@ -37,6 +37,7 @@ ENH: Ticket#890 - Minor optimization: Use $var===null over is_null($var) (Knut) ENH: Ticket#893 - Added page parameter to queryForPagedList() to specify the initial page to load (Michael) ENH: Ticket#896 - TTheme - enhance for subclassing (Knut) ENH: Ticket#898 - Minor optimization: Use (int) over intval() (Knut) +ENH: Ticket#813 - (Issue #13) TRegularExpressionValidator has new ClientSidePatternModifier property (Michael) ENH: Ticket#809 - "LIMIT 1" for ActiveRecord find() and findBy() (Carl) ENH: Ticket#848 - TCache "set" and "add" with empty values (Carl) ENH: Ticket#822 - Not receiving emails from TEmailLogRoute (Carl) diff --git a/framework/Web/Javascripts/source/prado/validator/validation3.js b/framework/Web/Javascripts/source/prado/validator/validation3.js index d94a6c0c..a3b803d8 100644 --- a/framework/Web/Javascripts/source/prado/validator/validation3.js +++ b/framework/Web/Javascripts/source/prado/validator/validation3.js @@ -1668,6 +1668,7 @@ Prado.WebUI.TRegularExpressionValidator = Class.extend(Prado.WebUI.TBaseValidato * @constructor initialize * @param {object} options - Additional constructor option: * @... {string} ValidationExpression - Regular expression to match against. + * @... {string} PatternModifiers - Pattern modifiers: combinations of g, i, and m */ /** @@ -1678,12 +1679,12 @@ Prado.WebUI.TRegularExpressionValidator = Class.extend(Prado.WebUI.TBaseValidato evaluateIsValid : function() { var value = this.getValidationValue(); - if (value.length <= 0) + if (value.length <= 0) return true; - var rx = new RegExp(this.options.ValidationExpression); - var matches = rx.exec(value); - return (matches != null && value == matches[0]); + var rx = new RegExp(this.options.ValidationExpression,this.options.PatternModifiers); + var matches = rx.exec(value); + return (matches != null && value == matches[0]); } }); diff --git a/framework/Web/UI/WebControls/TRegularExpressionValidator.php b/framework/Web/UI/WebControls/TRegularExpressionValidator.php index 125416f3..be861e45 100644 --- a/framework/Web/UI/WebControls/TRegularExpressionValidator.php +++ b/framework/Web/UI/WebControls/TRegularExpressionValidator.php @@ -96,7 +96,7 @@ class TRegularExpressionValidator extends TBaseValidator } /** - * @param string pattern modifiers, + * @param string pattern modifiers for server side validation, * see http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php */ public function setPatternModifiers($value) @@ -112,6 +112,23 @@ class TRegularExpressionValidator extends TBaseValidator return $this->getViewState('PatternModifiers', ''); } + /** + * @param string pattern modifiers for clientside. + * (Only 'g','i' and 'm' are available.) + */ + public function setClientSidePatternModifiers($value) + { + $this->setViewState('ClientSidePatternModifiers', $value); + } + + /** + * @return string clientside pattern modifiers, no modifiers by default. + */ + public function getClientSidePatternModifiers() + { + return $this->getViewState('ClientSidePatternModifiers', ''); + } + /** * Returns an array of javascript validator options. * @return array javascript validator options. @@ -120,6 +137,7 @@ class TRegularExpressionValidator extends TBaseValidator { $options = parent::getClientScriptOptions(); $options['ValidationExpression']=$this->getRegularExpression(); + $options['PatternModifiers']=$this->getClientSidePatternModifiers(); return $options; } } -- cgit v1.2.3