/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function is_proper_email($email) { // First, we check that there's one @ symbol, and that the lengths are right // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. return false; } // Split it into sections to make life easier if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name return false; // Not enough parts to domain } return false; } } } return true; } //usage // $email_result = is_proper_email($email_string); // $email_result will be either true or false