I want textbox validation for allowing only one . value and only numbers. Means my textbox value should take only numerics and one . value. Value shoul
.
try this one
private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != '.') e.Handled = true; // only allow one decimal point if (e.KeyChar == '.' && textBox1.Text.IndexOf('.') > -1) e.Handled = true; }