Re: Poll of sorts: Javascript Form validation or PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
- -@xxxxxxxxxxx

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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux