diff --git a/resources/functions.php b/resources/functions.php index b37ceea854..ba460c1a31 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -950,4 +950,16 @@ function number_pad($number,$n) { return str_pad((int) $number,$n,"0",STR_PAD_LEFT); } +// validate email address syntax +if(!function_exists('validate_email')) { + function valid_email($email) { + $regex = '/^[A-z0-9][\w.-]*@[A-z0-9][\w\-\.]+\.[A-z0-9]{2,6}$/'; + if ($email != "" && preg_match($regex, $email) == 0) { + return false; // email address does not have valid syntax + } + else { + return true; // email address has valid syntax + } + } +} ?>