Email validate function
Posted: Mon Sep 06, 2004 6:06 am
Hi all,
The following is my function for checking if an email address is in the correct format. Basically I want the function to only check if the email address field has been entered into or not, if it has then check validation if not don't bother trying to validate.
I just can't get it too work. Regardless of what I enter into the field the form will process, I know the form is ok and the call to the class is ok because I have other functions being tested also and they work.
Could someone please point me towards the direction of divine enlightenment
The following is my function for checking if an email address is in the correct format. Basically I want the function to only check if the email address field has been entered into or not, if it has then check validation if not don't bother trying to validate.
I just can't get it too work. Regardless of what I enter into the field the form will process, I know the form is ok and the call to the class is ok because I have other functions being tested also and they work.
Could someone please point me towards the direction of divine enlightenment
Code: Select all
// check whether email field has data in or not, if it does then validate
function isEmailOrEmpty($field, $msg)
{
if(isset($this->_getValueї$field]))
{
$pattern = "/^(їa-zA-Z0-9])+(ї\.a-zA-Z0-9_-])*@(їa-zA-Z0-9_-])+(\.їa-zA-Z0-9_-]+)+/";
if(preg_match($pattern, $value))
{
return true;
}
}
else
{
return false;
}
}