ASP Hosting sale!
Double disk space and transfer for FREE!
Limited time offer! Act Now!

aspdev | articles | tutorials | forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ASP.NET regularexpression validator validating email

 
Post new topic   Reply to topic    ASPdev.org Forum Index -> .NET Programming (ASP.NET, VB.NET, C#)
View previous topic :: View next topic  
Author Message
Don



Joined: 22 Oct 2004
Posts: 28

PostPosted: Fri Oct 22, 2004 8:47 am    Post subject: ASP.NET regularexpression validator validating email Reply with quote

Hi guys,

I'm trying to use regularexpression validator control in ASP.NET to validate an email address input field, but I can't get it right Sad.
Do you know of a regular expression that will validate email address?
If you know one, please post it here.


Thanks in advance,

Don
Back to top
View user's profile Send private message
administrator
Site Admin


Joined: 01 Oct 2004
Posts: 183

PostPosted: Fri Oct 22, 2004 10:28 am    Post subject: Reply with quote

Hi Don,

You can try the following regular expression for your email validation:

Code:
^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Z
a-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-z
A-Z]{2,6}$



Cheers
_________________
Peter
ASP & ASP.NET Articles and Tutorials
Back to top
View user's profile Send private message
swords



Joined: 11 May 2005
Posts: 1

PostPosted: Thu May 12, 2005 5:38 am    Post subject: Reply with quote

I have a simple code,just like this:
Code:
<asp:textbox id="tbemail" runat="server"/><br>
<asp:regularexpressionvalidator
runat="server"
controltovalidate="tbemail"
validationexpression="\w+\@\w+(\.com|\.net|\.org|\.cn|\.ca)"
errormessage="That is not a valid email"
display="dynamic"/><br>

_________________
http://wmjie.51.net/swords
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    ASPdev.org Forum Index -> .NET Programming (ASP.NET, VB.NET, C#) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group

SQL Tutorial