Validation to Check for Comma separated EmailIDs

Regular Exp Description:


List of Email ids separated with [,] Email ID may contain character set as [._-']

Regular Expression


^((\w+([-_.']\w+)*@\w+([-_.']\w+)*\.\w+([-_.']\w+)*)*([,])*)*$


Regular expression Rules:


Finite automata rule Values should proceed with email Ids with Comma Separated. No comma will precede the email IDs.

Matches:


abc.xyz@anonymous.com
abc.xyz@anonymous.com,abc-xyz@anonymous.com,abc_xyz@anonymous.com
abc.xyz@anonymous.com,com,D'Souza@anonymous.com

Non-Matches:


abc.xyz
,abc.xyz@anonymous.com
abc.xyz@anonymous.com,
abc

Javascript:



function CheckForCommaSeperatedEmailIDs( fieldValue )
{

var regex = /^((\w+([-_.']\w+)*@\w+([-_.]\w+)*\.\w+([-_.]\w+)*)*([,])*)*$/;
if( !fieldValue.match( regex ) )
{
alert('The Email IDs Invalid');

return false;

}
return true;
}


Comments

Guest Author: Abdul jabbar24 May 2012

Excellent tutorial



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: