Textbox validation

  • Thread starter Thread starter Stefan Richter
  • Start date Start date
S

Stefan Richter

I need to check if all digits entered in several textboxes are numbers
smaller then 100.000

When there is at least on error, I want to display an error message. When
all errors are fixed, the message should disappear again. An errorcounter
doesn't work, because 2 valid numbers would "delete 2 errors. Have I got to
use an errorvar for every field or is there a better way?





Thanks,



Stefan
 
You could use the textchanged event

private void textBox1_TextChanged(object sender, System.EventArgs e)
{
if( Convert.ToInt32( this.textBox1.Text ) >= 100000 )
{
this.label1.Text = "Error Message for user here.";
this.button1.Enabled = false;
}
else
{
this.button1.Enabled = true;
this.label1.Text = "Success message here";
}
}
 
Back
Top