<script type="text/javascript">
function checkEmail(eadd) {
eadd=eadd.replace(/^[\s]+/, ""); eadd=eadd.replace(/[\s]+$/, "");
if (eadd=="") {alert('Please enter an eMail address'); return false;}
var literal="[\x2D^!#$%&'*+/=?0-9A-Z_`a-z{|}~]+";
var quoted='"[\x20-\x7F]+"';
var word="("+literal+"|"+quoted+")";
var domn="([-0-9A-Z_a-z]+|"+quoted+")";
var emailAdd=word+"([.]"+word+")*@("+domn+"[.])+[a-zA-Z]{2,6}";
var litName="[\x2D\x20^!#$%&'*+/=?0-9A-Z_`a-z{|}~]+";
var quoName='"[\x00-\x09\x0E-\x21\u0023-\uFFFF]+"[\x20\t]*';
var emailFormat="("+emailAdd+"|("+litName+"|"+quoName+")<"+emailAdd+">)";
var emailList=emailFormat+"(,[\x20\t\n]*"+emailFormat+")*";
var emailValid=new RegExp("^"+emailList+"$");
if (emailValid.test(eadd)) return true;
else {
alert('The eMail address you entered has an invalid format. Please check it and try again');
return false; } }
</script>
<?php
Function validateEmailList($given) {
$literal="[-!#$%&'*+=?0-9A-Z^_`a-z{|}~\/]+";
$quoted='"[\x20\x21\x23-\x7F]+"';
$word="(?:".$literal."|".$quoted.")";
$domain="(?:[-0-9A-Z_a-z]+|".$quoted.")";
$emailAdd="(".$word."(?:[.]".$word.")*@(?:".$domain."[.])+[a-zA-Z]{2,6})";
$litName="[- !#$%&'*+=?0-9A-Z^_`a-z{|}~\/]+";
$quoName='"[\x01-\x09\x0E-\x21\x23-\xFF]+"[\x20\t]*';
$emailRecipient="(?:".$emailAdd."|(?:".$litName."|".$quoName.")<".$emailAdd.">)";
$emailList=$emailRecipient.'(?:,[\x20\t\n]*'.$emailRecipient.')*';
if (preg_match('/^'.$emailList.'$/', $given)==FALSE) return FALSE;
$list=array();
do { preg_match('/^'.$emailRecipient.'/', $given, $validated);
$list[]=array($validated[0], ($validated[1]!="") ? $validated[1] : $validated[2]);
$given=trim(substr($given, strlen($validated[0])+1)); }
while (strlen($given)>0);
return $list; }
?>