Improve company productivity with a Business Account.Sign Up


Only RequiredFieldValidator complains when textbox is blank

Posted on 2004-09-13
Medium Priority
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
  • 2

Accepted Solution

daffodils earned 750 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
To export Lotus Notes to Outlook PST or Exchange and Domino Server files to Exchange Server or PST files with ease, go for Kernel for Lotus Notes to Outlook conversion tool. Through the video, you can watch the conversion process. A common user with…

595 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