By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,064 Members | 1,445 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,064 IT Pros & Developers. It's quick & easy.

q: emial validation

P: n/a
Hello,
I need to validate e-mail, so I need to see if textbox matches
*@myDomain.com, how can I do this?
Thanks,
Jim.

Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You need to tie a regular expressionv alidator to a requried field validator
in your form. The validation expression below is a bit simple so you might
choose to find a better regexp, but the code should function to get you
running. I've not tried this code mind you....
<asp:textbox id="textbox1" runat="server"/>
<asp:RegularExpressionValidator id="valRegEx" runat="server"
ControlToValidate="textbox1"
ValidationExpression=".*@.*\..*"
ErrorMessage="* Your entry is not a valid e-mail address."
display="dynamic">*</asp:RegularExpressionValidator>You might also want
to try this as the validation
expression.ValidationExpression=".*@myDomain.com"
-- Regards
John Timney
ASP.NET MVP
Microsoft Regional Director

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com...
Hello,
I need to validate e-mail, so I need to see if textbox matches
*@myDomain.com, how can I do this?
Thanks,
Jim.

Nov 19 '05 #2

P: n/a
There are some other good regex patterns that check for legal email-address
patterns. You could easily modify them to fix the domain to a specific
string, if you like.

http://www.regexlib.com/DisplayPatterns.aspx
"John Timney (ASP.NET MVP)" <ti*****@despammed.com> wrote in message
news:eF**************@TK2MSFTNGP12.phx.gbl...
You need to tie a regular expressionv alidator to a requried field validator in your form. The validation expression below is a bit simple so you might choose to find a better regexp, but the code should function to get you
running. I've not tried this code mind you....
<asp:textbox id="textbox1" runat="server"/>
<asp:RegularExpressionValidator id="valRegEx" runat="server"
ControlToValidate="textbox1"
ValidationExpression=".*@.*\..*"
ErrorMessage="* Your entry is not a valid e-mail address."
display="dynamic">*</asp:RegularExpressionValidator>You might also want to try this as the validation
expression.ValidationExpression=".*@myDomain.com"
-- Regards
John Timney
ASP.NET MVP
Microsoft Regional Director

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com...
Hello,
I need to validate e-mail, so I need to see if textbox matches
*@myDomain.com, how can I do this?
Thanks,
Jim.


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.