Textbox validation

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
 
G

Guest

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";
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top