summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2013-02-04 19:48:43 +0100
committerAndrey Andreev <narf@bofh.bg>2013-02-04 19:48:43 +0100
commit1d6d278607f021e5c430192e14de641904575d5d (patch)
tree96cf7c5e59d45794724c9eb741ba816ca114fc78 /system
parent2ccb60ed153a7c86c31a230c08bd42f22111398a (diff)
parentf9866509fbe79186976a9e4b0ca1aaa7fe0bdc7b (diff)
Merge pull request #2220 from sajanNOPPIX/develop
New Form Validation Rule: alpha_numeric_spaces
Diffstat (limited to 'system')
-rw-r--r--system/language/english/form_validation_lang.php1
-rw-r--r--system/libraries/Form_validation.php13
2 files changed, 14 insertions, 0 deletions
diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php
index 3fb007dd2..7c0277c25 100644
--- a/system/language/english/form_validation_lang.php
+++ b/system/language/english/form_validation_lang.php
@@ -37,6 +37,7 @@ $lang['form_validation_max_length'] = 'The {field} field cannot exceed {param}
$lang['form_validation_exact_length'] = 'The {field} field must be exactly {param} characters in length.';
$lang['form_validation_alpha'] = 'The {field} field may only contain alphabetical characters.';
$lang['form_validation_alpha_numeric'] = 'The {field} field may only contain alpha-numeric characters.';
+$lang['form_validation_alpha_numeric_spaces'] = 'The {field} field may only contain alpha-numeric characters and spaces.';
$lang['form_validation_alpha_dash'] = 'The {field} field may only contain alpha-numeric characters, underscores, and dashes.';
$lang['form_validation_numeric'] = 'The {field} field must contain only numbers.';
$lang['form_validation_is_numeric'] = 'The {field} field must contain only numeric characters.';
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index bbd0b523e..1511d9add 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -1232,6 +1232,19 @@ class CI_Form_validation {
// --------------------------------------------------------------------
/**
+ * Alpha-numeric w/ spaces
+ *
+ * @param string
+ * @return bool
+ */
+ public function alpha_numeric_spaces($str)
+ {
+ return (bool) preg_match('/^[A-Z0-9 ]+$/i', $str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Alpha-numeric with underscores and dashes
*
* @param string