how to allow textbox to acccept only numbers and decimal point?
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);
Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.