TextBox Validation
Hi all i would like to validate a text box so that it should allow only numbers from 0-9 and A-Z(In capitals). Can any one tell how to do this
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
PJ MartinsPosted Jun 17, 2010, 4:55 PM
Dorababu MekaPosted Jun 17, 2010, 2:05 PM
PJ MartinsPosted Jun 17, 2010, 11:17 AM
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!System.Text.RegularExpressions.Regex.Match(e.KeyChar.ToString(), "[A-Z|0-9]").Success)
e.Handled = true;
}