how to allow textbox to acccept only numbers and decimal point?
Posted on 2008-06-24
i want to enter price value in my textbox.i want it to accept only numbers and one decimal point.right now its taking only numbers but not decimal point.the code i hav written is given below bt its only to accept numbers not decimal point.
string s = txtPrice.Text;
int chars = s.Length;
// char p = '.';
for (int i = 0; i < chars; i++)
if (!char.IsNumber(s, i))
MessageBox.Show("Enter only numbers");
txtPrice.Text = s.Remove(i, 1);