Only RequiredFieldValidator complains when textbox is blank

Posted on 2004-09-13
Last Modified: 2006-11-17
Of all the built-in validators, only RequiredFieldValidator complains when a textbox is blank.

e.g. Say we use RegularExpressionValidator to validate a REQUIRED e-mail address field. The validator does nothing if the user leaves the textbox blank (even if the regular expression requires more than zero characters).

An ugly workaround is: associating two validators with one control. Ugh. Suggestions?

Question by:stuart_wachsberg
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

daffodils earned 250 total points
ID: 12049320
The "RequiredFieldValidator" is the ONLY validation control that ensures that the associated input control is a REQUIRED field.
All other Validation controls assume the control's data as VALID if it is EMPTY.

If a value is REQUIRED required for the associated input control, use a "RequiredFieldValidator" control in addition to the "RegularExpressionValidator" control. Multiple validators can be associated with the same input control.

Author Comment

ID: 12049382
Just as I thought. Too bad MS didn't add a "required field" property to all the validators. Just about every validated field I come across is required.


Expert Comment

ID: 12049410
Yes, that's true.. it is very cumbersome having to place two validators with every control !

Also be careful when using data Type validations.. most validation controls assume value to be valid if it cannot be converted to the data type specified by the "Type" property, except for of course CompareValidator.. so there you go.. another validator!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question