How to validate text box with C# in windows application ?

Samirbhogayta
Posted by Samirbhogayta under ASP.NET category on | Points: 40 | Views : 1745
private void TextBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar >= 47 && e.KeyChar <= 58) || (e.KeyChar == 46) || (e.KeyChar == 8))
{
e.Handled = false;
}
else
{
e.Handled = true;
MessageBox.Show("Please enter only number");
}
}

Comments or Responses

Login to post response