conditional validation check on 2nd email that isn't required
PHP Code:
// variable is $friendemail1 and IS required
elseif (!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$",strtolower($c['friendemail1']))) {
$error_msg .= "Friend email is not a valid e-mail address. \n";
}
// variable is $friendemail2 but isn
elseif (!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$",strtolower($c['friendemail2']))) {
$error_msg .= "Friend 2 email is not a valid e-mail address. \n";
}
By default this is checking both, but I'm trying to get it to only run the check on friendemail2 when that field is filled out.
I tried sometihng like
elseif ($friendemail2 != ''; ) (!ereg...
so if field friendemail2 isn't blank run the rest of the check, but couldn't get it to work. Anyone have any suggestions? Thank you.