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
  • 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

778 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