Hi
I want the user to only type letters (a-z simple or capital) in the Name textbox.If the user types any other character(like numbers or commas,semicolons) I want to show a message.How can I check for it(in C#)?
Thnx in Advance

Place this below code into button click if you want to check or to textchanged event.

bool isStrictMatch = false;
            string patternStrict = @"^([a-zA-Z]+)$";
            Regex reStrict = new Regex(patternStrict);
            if (txtSecond.Text.Trim() != string.Empty)
            {
                isStrictMatch = reStrict.IsMatch(txtSecond.Text.Trim());
                if (!isStrictMatch)
                    MessageBox.Show("Please use alphabetics", "Validation", MessageBoxButtons.OK);
            }

Hi
thnx it wrks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.