Php validation of emailtel and other formats
function isValidEmail($email) { $email = strtolower($email); if (!preg_match(“/[^@]{1,64}@[^@]{1,255}/”, $email)) { return false; } $email_array = explode(“@”, $email); $local_array = explode(“.”, $email_array[0]); $length = sizeof($local_array); for ($i = 0; $i < $length; $i++) { if (!preg_match(“@^[a-z0-9_~-][a-z0-9_~.-]{0,63}$@”, $local_array[$i])) { return false; } } unset($length); if (!preg_match(“@^\[?[0-9\.]+\]?$@”, $email_array[1])) { $domain_array = explode(“.”, $email_array[1]); $length = sizeof($domain_array); if ($length < 2) { return false; } for ($i = 0; $i < $length; $i++) { if (!preg_match(“/^(([a-z0-9][a-z0-9-]{0,61}[a-z0-9])|([a-z0-9]+))$/”, $domain_array[$i])) { return false; } } unset($length); } return true; }
2. verify that the mobile phone is compliant with the standard function isValidCellPhone ($ cellPhone) {$ flag = FALSE; if (preg_match ('@ ^ 1 [3458] [0-9] {9 }$ @', $ cellPhone) {$ flag = TRUE;} return $ flag ;} 3. verify that the phone number complies with the standard function isValidPhone ($ phone) {if (preg_match ('@ ^ 1 [3458] [0-9] {9} $ @', $ phone )) {return true;} if (preg_match ('@((? :(? :(? : 00860? | 0 )(? : 10 | 2 \ d | [3-9] \ d ))-?)? ([2-8] \ d {6, 7}) @ ', $ phone) {return true;} if (preg_match (' @ ^ ([48] 00 (? : \ D {7} |-\ d {7} |-\ d {3}-\ d {4} |-\ d {4}-\ d {3} | \ d-\ d {3}-\ d {3 })) $ @ ', $ phone) {return true;} return false ;}