C# windows application
sir, i am having textbox in that i have to enter like this only allow numbers and hipan( 2013-2014) without using rex control... send me code
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Brijendra GautamRank #1,900 · 778 reputationPosted Mar 13, 2014, 1:26 AM EDT
If you can use Regex then this is the simplest code
Regex objReg = new Regex("[^0-9\\-]");
if (!objReg.IsMatch(txtTest.Text))
{
MessageBox.Show("Success");
}
Or if you don't want to use Regex then you can use this code
bool success = true;
List
foreach (char c in txtTest.Text)
{
if(!strAllowed.Contains(c.ToString()))
{
MessageBox.Show("fail");
success = false;
}
}
if(success)
MessageBox.Show("Success");