Advertisement
Guest User

Untitled

a guest
Sep 15th, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. textBox.KeyPress += new KeyPressEventHandler(textBox_KeyPress);
  2.  
  3. private void textBox_KeyPress(object sender, KeyPressEventArgs e)
  4. {
  5. if (e.KeyChar < 65 || e.KeyChar > 122)
  6. {
  7. e.Handled = true;
  8. }
  9. }
  10.  
  11. if (!Regex.IsMatch(textbox.Text, @"[a-zA-Z]"))
  12. {
  13. yourErrorProvider.setError(textbox, "Only A-Z accepted.");
  14. }
  15.  
  16. if ((Convert.ToInt32(e.KeyChar) >= 65) && (Convert.ToInt32(e.KeyChar) <= 122))
  17.  
  18. {
  19. errorProvider1.SetError(textBox1, "OK");
  20. errorProvider2.SetError(textBox1, "");
  21. }
  22. else
  23. {
  24. errorProvider2.SetError(textBox1, "Can not enter the numbers...");
  25. errorProvider1.SetError(textBox1, "");
  26. textBox1.Text = "";
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement