From 2d1608a6325d55ab31c55c27c31052c2daa76e46 Mon Sep 17 00:00:00 2001 From: Sajan Parikh Date: Sat, 2 Feb 2013 08:00:39 -0600 Subject: Added Form Validation rule for alphanum + spaces. Signed-off-by: Sajan Parikh --- system/libraries/Form_validation.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'system/libraries/Form_validation.php') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index bbd0b523e..7b9215c04 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1229,6 +1229,21 @@ class CI_Form_validation { return ctype_alnum((string) $str); } + // -------------------------------------------------------------------- + + // -------------------------------------------------------------------- + + /** + * Alpha-numeric w/ spaces + * + * @param string + * @return bool + */ + public function alpha_numeric_spaces($str) + { + return (bool) preg_match('#^[A-Z0-9 ]+$#i', $str); + } + // -------------------------------------------------------------------- /** -- cgit v1.2.3-24-g4f1b From df3bfed9c19fe22d6449e2ee78ca5bd2fe9c6476 Mon Sep 17 00:00:00 2001 From: Sajan Parikh Date: Mon, 4 Feb 2013 12:25:49 -0600 Subject: Cleaned up for pull request. Signed-off-by: Sajan Parikh --- system/libraries/Form_validation.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'system/libraries/Form_validation.php') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 7b9215c04..1511d9add 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1229,8 +1229,6 @@ class CI_Form_validation { return ctype_alnum((string) $str); } - // -------------------------------------------------------------------- - // -------------------------------------------------------------------- /** @@ -1241,7 +1239,7 @@ class CI_Form_validation { */ public function alpha_numeric_spaces($str) { - return (bool) preg_match('#^[A-Z0-9 ]+$#i', $str); + return (bool) preg_match('/^[A-Z0-9 ]+$/i', $str); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b