Re: Form Validation
| From: | Wico de Leeuw | Date: | Tue, 08 Aug 2000 16:00:49 +0000 |
| Subject: | Re: Form Validation | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-10717@lists.php.net to get a copy of this message | ||
At 16:21 8-8-00 +0100, Robin Vickery wrote:
dave@musiccity.net (Dave Daniels) writes: To check email, you can use a function like this: function validateEmail($email) { if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.(com|net|edu|org|mil))$",$ email)){ return 1; } else { return 0; } } Don't use this regular expression; It will deny many valid addresses (everything with a country top level domain for a start), and it'll allow through a lot of invalid ones.Better use this one: function Validate_Email ($email) {
eturn (preg_match("'^[a-z0-9_.=-]+@([a-z0-9-]+\.)+([a-z]{2,3})\$'i", $email));
}
Greetz,
Wico
-robin-- Robin Vickery............................................... Planet-Three, 3A West Point, Warple Way, London, W3 0RG, UKEmail: robin@planet-three.co.uk Phone: +44 (0)794 670 6395-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net