I'm writing some code to sanitise input. For examples sake, let's use the following (note that I know to use PreviewInput for numerics, this is just for examples sake):
static bool IsDigitsOnly(string str)
{
return str.All(c => (c >= '0' && c <= '9') || c == '.');
}
private void KeyUpTextBoxNumberCheck(object sender, KeyEventArgs e)
{
if (!IsDigitsOnly(TextBoxExternalReferralOther1.Text))
{
TextBoxExternalReferralOther1.Text = "";
}
}
I'm trying to update KeyUpTextBoxNumberCheck
so it can work with multiple textboxes. How can I update it so that the textboxes aren't hardcoded and instead come from the sender?