From fe5e72231399846aa4acf661f6b354912e77d1b2 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Mon, 20 Apr 2009 00:13:13 +0000 Subject: [PATCH] BUGFIX Fixing CurrencyField serverside and javascript validation to accept numbers with leading or trailing spaces git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@74725 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/CurrencyField.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/forms/CurrencyField.php b/forms/CurrencyField.php index a4812105d..c1c32cdc9 100755 --- a/forms/CurrencyField.php +++ b/forms/CurrencyField.php @@ -50,7 +50,7 @@ Behaviour.register({ if(!el || !el.value) return true; var value = \$F(el); - if(value.length > 0 && !value.match(/^\\$?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?\$/)) { + if(value.length > 0 && !value.match(/^\s*\\$?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?\s*\$/)) { validationError(el,"$error","validation",false); return false; } @@ -68,7 +68,7 @@ JS; } function validate($validator) { - if(!empty ($this->value) && !preg_match('/^\$?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$/', $this->value)) { + if(!empty ($this->value) && !preg_match('/^\s*\$?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?\s*$/', $this->value)) { $validator->validationError($this->name, _t('Form.VALIDCURRENCY', "Please enter a valid currency."), "validation", false); return false; }