Help validating email addresses

G

Guest

I am using a RegularExpressionValidator control on my ASP page, and I have
the ValidationExpression property set to "Internet E-mail Address". The
email address is valiated when the user puts in a email addess in the TextBox.

This works fine until I have multiple email addresses. How can I validate
multiple e-mail addresses seperated by a "," or ";"? The following
ValidationExpression will validate up to 2 email addresses but not anymore:

\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*([,;]\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*

Any suggestion would be helpful. The number of emails could be infinite,
but I think the max will be 10 at most.

Thanks,
 
G

Guest

Thanks Phillip.

For my future reference where can I look to find out what all these switches
mean?

Phillip Williams said:
^(\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*\b([,;]\s?)?)*$
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


SAL said:
I am using a RegularExpressionValidator control on my ASP page, and I have
the ValidationExpression property set to "Internet E-mail Address". The
email address is valiated when the user puts in a email addess in the TextBox.

This works fine until I have multiple email addresses. How can I validate
multiple e-mail addresses seperated by a "," or ";"? The following
ValidationExpression will validate up to 2 email addresses but not anymore:

\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*([,;]\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*

Any suggestion would be helpful. The number of emails could be infinite,
but I think the max will be 10 at most.

Thanks,
 
G

Guest

The only references I have ever used on Regular Expressions were these ones
on the MSDN
http://msdn.microsoft.com/library/d...de/html/cpconRegularExpressionsAsLanguage.asp

http://msdn.microsoft.com/library/d...html/ab0766e1-7037-45ed-aa23-706f58358c0e.asp

There are however some more popular sites that I saw their links posted on
this newsgroup frequently such as http://www.regexplib.com/

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


SAL said:
Thanks Phillip.

For my future reference where can I look to find out what all these switches
mean?

Phillip Williams said:
^(\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*\b([,;]\s?)?)*$
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


SAL said:
I am using a RegularExpressionValidator control on my ASP page, and I have
the ValidationExpression property set to "Internet E-mail Address". The
email address is valiated when the user puts in a email addess in the TextBox.

This works fine until I have multiple email addresses. How can I validate
multiple e-mail addresses seperated by a "," or ";"? The following
ValidationExpression will validate up to 2 email addresses but not anymore:

\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*([,;]\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*

Any suggestion would be helpful. The number of emails could be infinite,
but I think the max will be 10 at most.

Thanks,
 
G

Guest

Great. Thanks again Phillip.

That website you referenced is where I first found somewhat what I was
trying to do. After I sent my question out to this discussion board I got it
working. However, you solution was a better and not as long as mine so I use
it instead. I made a slight modification to it, so it would accept IP
addresses in the domain as well.

Thanks again.

Phillip Williams said:
The only references I have ever used on Regular Expressions were these ones
on the MSDN:
http://msdn.microsoft.com/library/d...de/html/cpconRegularExpressionsAsLanguage.asp

http://msdn.microsoft.com/library/d...html/ab0766e1-7037-45ed-aa23-706f58358c0e.asp

There are however some more popular sites that I saw their links posted on
this newsgroup frequently such as http://www.regexplib.com/

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


SAL said:
Thanks Phillip.

For my future reference where can I look to find out what all these switches
mean?

Phillip Williams said:
^(\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*\b([,;]\s?)?)*$
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


:

I am using a RegularExpressionValidator control on my ASP page, and I have
the ValidationExpression property set to "Internet E-mail Address". The
email address is valiated when the user puts in a email addess in the TextBox.

This works fine until I have multiple email addresses. How can I validate
multiple e-mail addresses seperated by a "," or ";"? The following
ValidationExpression will validate up to 2 email addresses but not anymore:

\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*([,;]\s*\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)*

Any suggestion would be helpful. The number of emails could be infinite,
but I think the max will be 10 at most.

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top