You need to validate what is entered
onKeyPress.
Handle the event, change the color and restrict user as per you want.
Sample:
private void txtBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar > 47 && e.KeyChar < 58) || (e.KeyChar == 46) || (e.KeyChar == 8))
{
}
else
{
}
}