Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Only RequiredFieldValidator complains when textbox is blank

Posted on 2004-09-13
3
Medium Priority
?
328 Views
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?



0
Comment
Question by:stuart_wachsberg
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
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.
0
 

Author Comment

by:stuart_wachsberg
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.

Thanks.
0
 
LVL 8

Expert Comment

by:daffodils
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!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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 …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Screencast - Getting to Know the Pipeline

972 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