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

Regular Expression / Required Field Validator

P: n/a
I am using the Regular Expression Validator control to validate a
correct email address. But, at the same time I would like to make it a
required field.

I tested by using just the regular expression validator expecting a
message to be displayed but it let me submit the form. Do I have to use
both?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Yes. All validators other than required return IsValid = true when they are
blank.

bill

"John ." <jr****@yahoo.com> wrote in message
news:OA*************@TK2MSFTNGP12.phx.gbl...
I am using the Regular Expression Validator control to validate a
correct email address. But, at the same time I would like to make it a
required field.

I tested by using just the regular expression validator expecting a
message to be displayed but it let me submit the form. Do I have to use
both?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #2

P: n/a
With the way the MS validators are set up, you may need both. Regex,
technically, should check for the condition and not allow an empty string. I
am not sure if you place in a condition to check for empty vals how it will
handle it, as I have not tested it.

Personally, I find the validation controls, other than the custom validator,
to be a waste of time on anything other than a very simple form.
---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"John ." wrote:
I am using the Regular Expression Validator control to validate a
correct email address. But, at the same time I would like to make it a
required field.

I tested by using just the regular expression validator expecting a
message to be displayed but it let me submit the form. Do I have to use
both?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #3

P: n/a
Yup...you'd think you wouldn't....you can always create your own
RegularExpressionValidator which simply expands the built-in
regularexpressionvalidator...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"John ." <jr****@yahoo.com> wrote in message
news:OA*************@TK2MSFTNGP12.phx.gbl...
I am using the Regular Expression Validator control to validate a
correct email address. But, at the same time I would like to make it a
required field.

I tested by using just the regular expression validator expecting a
message to be displayed but it let me submit the form. Do I have to use
both?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #4

P: n/a
You can add a RequiredFieldValidator in addition to your RegExValidator to
do the additional validation check.

-Brock
DevelopMentor
http://staff.develop.com/ballen
I am using the Regular Expression Validator control to validate a
correct email address. But, at the same time I would like to make it
a required field.

I tested by using just the regular expression validator expecting a
message to be displayed but it let me submit the form. Do I have to
use both?

*** Sent via Developersdex http://www.developersdex.com *** Don't just
participate in USENET...get rewarded for it!


Nov 19 '05 #5

P: n/a
In case you want a better set of validators, my "Professional Validation And
More" (http://www.peterblum.com/vam/home.aspx) addresses most of the
complaints users have with the ASP.NET validators. For example, my
RegexValidator has a property IgnoreBlankText. When true, it works like the
ASP.NET Regex validator. When false, it reports an error when the TextBox is
blank. There are literally hundreds of improvements like this that will make
it easy to match your validation requirements to my controls.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"John ." <jr****@yahoo.com> wrote in message
news:OA*************@TK2MSFTNGP12.phx.gbl...
I am using the Regular Expression Validator control to validate a
correct email address. But, at the same time I would like to make it a
required field.

I tested by using just the regular expression validator expecting a
message to be displayed but it let me submit the form. Do I have to use
both?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.