9 September 2006
ASP.NET Custom Validator
Posted by Mikhail Esteves under: C#; Tips .
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 :/
One Comment so far...
Tim Howland Says:
14 June 2008 at 12:23 am.
Starting with .NET 2.0, no need to add a RequiredFieldValidator: simply set myCustomValidator.ValidateEmptyText = true;