hi,
I have a textbox where i dont want numbers to be typed.I have a code for it but when the user types only letters and goes to a new line and saves it wont allow to save.How can i fix this?

Match matchFullNameRegex = Regex.Match(fullNameTextBox.Text, "^[a-zA-Z ]*$");

        if (!matchFullNameRegex.Success)
        {
            MessageBox.Show("Please insert only letters in FullName.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            fullNameTextBox.Focus();
            isValid = false;
        }

Recommended Answers

All 3 Replies

In what event is the code you posted?
How is isValid used?
Did you consider blocking all but number keys using the KeyDown event?

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.