diff options
Diffstat (limited to 'system')
-rw-r--r-- | system/language/english/form_validation_lang.php | 1 | ||||
-rw-r--r-- | system/libraries/Form_validation.php | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php index 3bc4515f5..1230ce566 100644 --- a/system/language/english/form_validation_lang.php +++ b/system/language/english/form_validation_lang.php @@ -55,6 +55,7 @@ $lang['form_validation_greater_than'] = 'The {field} field must contain a numbe $lang['form_validation_greater_than_equal_to'] = 'The {field} field must contain a number greater than or equal to {param}.'; $lang['form_validation_between'] = 'The {field} field must contain a number between {param}.'; $lang['form_validation_in'] = 'The {field} field must be within a predetermined list: {param}.'; +$lang['form_validation_date'] = 'The {field} field must be a proper date.'; /* End of file form_validation_lang.php */ /* Location: ./system/language/english/form_validation_lang.php */
\ No newline at end of file diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index e98c87f81..3e8204eee 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1475,6 +1475,31 @@ class CI_Form_validation { // -------------------------------------------------------------------- /** + * Value should be a valid date + * + * @param string + * @return bool + */ + public function date($date) + { + if (strtotime($date) === FALSE) + { + return FALSE; + } + + if ($date instanceof DateTime) + { + return TRUE; + } + + $date = date_parse($date); + + return checkdate($date['month'], $date['day'], $date['year']); + } + + // -------------------------------------------------------------------- + + /** * Is a Natural number (0,1,2,3, etc.) * * @param string |