ASP.NET Custom Validator

If you ever had problems with a Custom Validator not firing when it needs to, remember that it does not work on empty controls! I found this after a lot of frustration!

The MSDN says:

If the input control is empty, no validation functions are called and validation succeeds. Use a RequiredFieldValidator control to require the user to enter data in the input control.

So you would need to have a RequiredFieldValidator to check emptyness first :/

  • Share/Bookmark

1 Comment

Tim HowlandJune 14th, 2008 at 12:23 am

Starting with .NET 2.0, no need to add a RequiredFieldValidator: simply set myCustomValidator.ValidateEmptyText = true;

Leave a comment

Your comment