Regular Expression / Required Field Validator

J

John .

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?
 
W

William F. Robertson, Jr.

Yes. All validators other than required return IsValid = true when they are
blank.

bill
 
G

Guest

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!
***************************
 
B

Brock Allen

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

Peter Blum

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: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 

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

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,742
Latest member
AshliMayer

Latest Threads

Top