Today I come with a problem that I have not been able to solve, I have a textbox that should only be able to insert numbers, commas, and points.
I have a validation but this validation allows to insert signs of admiration, interrogation, among others.
I'm doing the validation with the KeyPress event
if (Char.IsNumber(e.KeyChar))
{
e.Handled = false;
}
else if (Char.IsControl(e.KeyChar))
{
e.Handled = false;
}
else if (Char.IsPunctuation(e.KeyChar))
{
e.Handled = false;
}
else
{
toolTip1.IsBalloon = true;
toolTip1.Show("Solo se permiten numeros", txtLimite, 3000);
e.Handled = true;
}
Expected example: 1,500.50
Example of error: 1,500.00!?!? among other signs.