I have three text boxes in which data has to be inserted and then via ADO.NET stored in SQL database,the three text boxes are Customer First Name,Customer Last Name and Contact Number,thus using ASCII code one has to restrict data that only alphabets are accepted in the first two text boxes and numbers in the third text box,there should also be a restriction so as to see that the maximum number of digits in the third text box is limited to 12 or 11,actually this was the work of my team member but he has run off leaving me in a fix,I am not too comfortable with this and it's become a huge problem,please do let me know what coding needs to be done to ensure this type of restriction and validation.
Use a regular expression for the first two. (http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.r...) You can use int.TryParse to determine if it is an integer. (double.TryParse for a double) for the limited digits use textBox.Text.Length.
cowsay Moo
cowthink 'Dude, why are you staring at me.'
I have tried the initial validation and it worked just right and I am left with the ASCII part as of now so I coded something which just isn't working,what's wrong with this code?
private void textBox1_Validating(object sender, CancelEventArgs e)
{
string s = textBox1.Text;
char[] c = s.ToCharArray();
for (int i = 0; i = 65 && c[i] = 97 && c[i]
Don't use break.
e.Cancel = true;
cowsay Moo
cowthink 'Dude, why are you staring at me.'