Click here to Skip to main content
Click here to Skip to main content

Tagged as

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

, 28 Dec 2012 CPOL
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
No Biography provided

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