Hi
in my code i have created a textbox that allows only numbers,but when i go to next control then it shows an error message "input is not valid".Eventhough i haven't created an error provider control to that text box.How can i fix it?
Can anyone help me please...?


Ravi KumarRank #2,085 · 690 reputationPosted Sep 12, 2015, 2:46 AM EDT
Rojalin SahooRank #2,919 · 493 reputationPosted Sep 12, 2015, 4:30 AM EDT
Vivek Joy139 reputationPosted Sep 13, 2015, 8:28 PM EDT
Raja TRank #685 · 3.5K reputationPosted Sep 13, 2015, 8:38 PM EDT
Vivek Joy139 reputationPosted Sep 14, 2015, 12:20 AM EDT
Raja TRank #685 · 3.5K reputationPosted Sep 14, 2015, 12:23 AM EDT
Vivek Joy139 reputationPosted Sep 14, 2015, 12:26 AM EDT
Raja TRank #685 · 3.5K reputationPosted Sep 14, 2015, 2:07 AM EDT
Vivek Joy139 reputationPosted Sep 18, 2015, 10:36 PM EDT
Raja TRank #685 · 3.5K reputationPosted Sep 19, 2015, 12:57 AM EDT
Try like
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 == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
{
e.Handled = true;
}
}