note 13196 deleted from function.ereg by jimw

From: Date: Fri, 02 Nov 2001 01:27:45 +0000
Subject: note 13196 deleted from function.ereg by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-20145@lists.php.net to get a copy of this message
The main example did not work for me, but this does: /* @func check_date_format() This function checks to see if a DATE has the correct format Format: check_date_format("$field", "$field_visible_name='hide'", "$format='MM/DD/YYYY'"); field_visible_name is not echoed out by default You only have to define the $field vaule but: If you define other values, all values to the left must also be defined. Paramaters: $field: the name of the input text field $field_visible_name: the name you want the user to understand $format: date,default = MM/DD/YYYY (we can add others as they are needed) Returns:$return: If fail, error message, else NULL */ function check_date_format($field, $field_visible_name='hide',$format='MM/DD/YYYY') { if ($format = 'MM/DD/YYYY') { if (!ereg ("^[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}$", $field)) { if ($field_visible_name == 'hide') { $message = "This field is not in the correct format. Please use $format."; return $message; } else { $message = "$field_visible_name is not in the correct format. Please use $format."; return $message; } } } }

« previous php.notes (#20145) next »