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);
txtPrice.Select(txtPrice.T
ext.Length
, 0);
return;
}
Start Free Trial