If I understand your problem correctly, I wouldn't be putting this code in the form.
I'd create a new TextBox control that implements the validation code and a setting telling it if it should even run. All you have to do is create a class that inherits from TextBox. Use your new TextBox in place of the TextBoxes you want to validate on your form. Each of these can check its own value and return a true/false if the value passes validation.
You could start with something simple, like this:
public class ValidatingTextBox : TextBox
{
public bool ShouldValidate { get; set; }
public bool IsValueOk()
{
bool returnValue = true;
if (ShouldValidate)
{
if (!string.IsNullOrWhitespace(Text))
{
returnValue = false;
}
}
return returnValue;
}
}
Now you don't have to filter out based on tag value. You can just tell each ValidatingTextBox whether it should validate itself or not simple by setting its ShouldValidate property to true.