Hello daniweb chums
I once again cannot seems to get a simple bit of text box validation working
I am trying to detect if a first name entered contains a number by converting the text box text into a char array and then convert each character entered (using a for loop) to char and catch the format exception when a number is entered. *Deep Breath*
Any thoughts?
And please don't just tell me not to do it this way unless it is impossible
Thanks in advance :)
Char[] fnchar;
char n;
fnchar = tbname.Text.ToCharArray();
for (int p = 0; p < fnchar.Length; p++)
{
try
{
n = fnchar[p];
tbname.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(179)))), ((int)(((byte)(113)))));
fni = true;
}
catch (FormatException)
{
fni = false;
tbname.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(205)))), ((int)(((byte)(112)))), ((int)(((byte)(84)))));
}
}