Re: Poll of sorts: Javascript Form validation or PHP

From: Date: Sun, 07 Dec 2008 13:49:18 +0000
Subject: Re: Poll of sorts: Javascript Form validation or PHP
References: 1 2 3 4 5 6 7  Groups: php.general php.general 
Request: Send a blank email to php-general+get-284254@lists.php.net to get a copy of this message
Ashley Sheridan wrote:
On Sun, 2008-12-07 at 02:27 -0800, Yeti wrote:
I put a small one together using regular expressions, http://www.ashleysheridan.co.uk/coding_php_validation.php
So we are "regexing" emails again? #OUT OF coding_php_validation.php COPY case 'email': { $expression = "/^([a-z0-9_\-\.]+)@([a-z0-9_\-\.]+)\.([a-z]{2,5})$/i"; $errorText = "The email does not appear to be a valid type."; break; } #END COPY What should be valid email addresses according to RFC 2822 [1]: !#$%&*+-/=?^_`{|}~@example.com "@"@example.com Not valid email addresses: "\"@example.com @@example.com - -@example.com Valid email addresses according to the Multipurpose Internet Mail Extension (MIME) [2]: ä@example.com Ã(c)@℞.com
Yes, I know I'm going to hell, but it serves well for most purposes. In the future when I actually see people use those kind of email addresses then I'll update it. Ash www.ashleysheridan.co.uk
basically if it has 1 or more printable chars followed by an @ followed by 1 - 63 printable chars followed by a period followed by a valid domain extension it's good; that's simple regex :p

« previous php.general (#284254) next »