Regular Expression / Required Field Validator

  • Thread starter Thread starter John .
  • Start date Start date
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?
 
Yes. All validators other than required return IsValid = true when they are
blank.

bill
 
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!
***************************
 
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
 
Back
Top