Thursday, February 23, 2012

CustomValidator not firing with TextBox

PROBLEM: You've added a CustomValidator control to your page and for some reason the validation isn't firing.
SOLUTION: In my case it was ValidateEmptyText="true" needed to be added. Also if you're using multiple validation groups on the page make sure you set your ValidationGroup property as well.

Also remember when you use a CustomValidator to ensure you add a Page.IsValid check on your submission button to prevent anything progressing further if the custom validation is false.