How to validate a numeric field?
I need to validate a field which is numeric. Can anyone point me in the right direction?
I am really new to programming and do not know how to go about crreating a method or furnction to validate a textbox field every time a user enters data into it.
Thanks in advance,
Lee
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

jose.acidrain13 reputationPosted Feb 23, 2004, 11:40 PM EST
mhelal22 reputationPosted Mar 3, 2004, 5:18 AM EST
private bool ValidateData(string data, DataType type) { if(type == DataType.Number) { for(int i =0; i< data.Length;i++) { int charUn = Convert.ToInt32(data[i]); if((charUn >= 48) && (charUn <= 57)) { continue; } else { return false; } } return true; } else { for(int i =0; i< data.Length;i++) { int charUn = Convert.ToInt32(data[i]); if(((charUn >= 65) && (charUn <= 90)) ||((charUn >= 97)&&(charUn <= 122)) ||(charUn == 32)) { continue; } else { return false; } } return true; } }
hope useful!