Tuesday 23 July 2013

Validate a TextBox to contain only particular data

This code validate a text box to cantain only alphabets.
If u want to change then you can replace IsLetter to any type .


  protected void TextBox1_TextChanged(object sender, EventArgs e)
    {
        if (TextBox1.Text.All(chr => char.IsLetter(chr)))
        {
          
                Label1.Text = "ok";
           
        }
        else
        {
            Label1.Text = "not ok";
           
        }
    }

No comments:

Post a Comment