Long E-mail Validation

function validate_email($email){ $isValid = TRUE; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex){ $isValid = FALSE; }else{ $domain = substr($email, $atIndex + 1); $local = substr($email, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if (!preg_match('/^([\w\.\-]+)@([a-z0-9\.\-]+\.[a-z]{2,6})$/i',trim($email),$m)){ $isValid = FALSE; return $isValid; } if($localLen < 1 || $localLen > 64){ $isValid = FALSE; }elseif($domainLen < 1 || $domainLen > 255){ $isValid = FALSE; }elseif($local[0] == '.' || $local[$localLen - 1] == '.'){ $isValid = FALSE; }elseif(preg_match('/\\.\\./', $local)){ $isValid = FALSE; }elseif(!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)){ $isValid = FALSE; }else if (preg_match('/\\.\\./', $domain)){ $isValid = FALSE; }else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\", "", $local))){ if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\", "", $local))){ $isValid = FALSE; } } } return $isValid; }

1 Response

Muy parecida a la mía, la publicaré pronto.

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.