EMAIL VALIDATION with regular expressions

  • Thread starter Thread starter Marlon
  • Start date Start date
M

Marlon

How can modify this expression
\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
to validate multiple email address separator by comma and/or semicolon

e.g. (e-mail address removed);[email protected]
 
Hi you can use the following script:

if( multiEmail() )
document.PdfEmailForm.submit();


function multiEmail()
{
var str=document.PdfEmailForm.to.value;
var email = str.split(',');
for (var i = 0; i < email.length; i++)
{
if(!checkemail(email))
{
alert('one or more
email addresses are not
valied');
return false;
}

}
return true;
}

function checkemail(email)
{
var str=document.PdfEmailForm.from.value;

var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

if (filter.test(str) && filter.test(email))
return (true)
else
return(false)

}

where :

document.PdfEmailForm.to.value - E-mail ids what we enter in TO field.

document.PdfEmailForm.from.value - E-mail ids what we enter in TO field.


**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
another good place for regex stuff is regexlib.com

--
Regards
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc, Amazon, B&H etc
 
Back
Top