Click here to Skip to main content
13,057,089 members (44,783 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

0 views
Posted 28 Dec 2012

to validate for numbers and alphabets in c# asp.net2.0 in codebehind file

, 28 Dec 2012
Hi,Try this:bool includesNotOnlyNumeric = Regex.IsMatch(textBox.Text, @"\D");if (includesNotOnlyNumeric){ // don't show an alert box}else{ // show an alert box}

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

28 Dec 2012
OriginalGriff
You could use a Regex: string str = myTextBox.Text; Regex includesNonNumeric = new Regex(@"[^\d]"); if (includesNonNumeric.IsMatch(str)) { // OK } else { //...
28 Dec 2012
nityasri
2 alternatives  
to validate for numbers and alphabets in c# asp.net2.0 in codebehind file,the textbox should accept all numbers,alphabets,special characters...but textbox should not contain only numbers if it contains only numbers error message in alert box should be thrown..please help me how to code in c#.net...

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

ProgramFOX
Belgium Belgium
I'm a hobbyist programmer. I work mostly in C#, JavaScript, and Python. I also like chess; you can find me on Lichess.

| | Privacy | Terms of Use | Mobile
Web02 | 2.8.170728.6 | Last Updated 29 Dec 2012
Article Copyright 2012 by ProgramFOX
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid