如何只允许在带遮罩的文本框中显示字母

问题描述:

我在表单中使用蒙版文本..我只允许在蒙版文本框中使用字母..我验证了文本框只允许将字母作为普通文本框使用,但允许数字使用..pls提供了解决方案它...

Im using masked text in my form..I want to allow only alphabets in the masked textbox..i validated the text box for only allowing alphabets as the normal text box but it is allowing numbers..pls give the solution for it...

您显然没有正确验证它.我倾向于自己控制,因为带遮罩的文本框仅会告诉您何时输入了错误的内存.在按键或按键事件中,检查Char.IsControl和Char.IsAlpha,如果它们均失败,则拒绝按键.
You''re obviously not validating it properly. I tend to make my own control, because the masked text box just tells you when you entered something wrong, from memory. In the key press or key down event check Char.IsControl and Char.IsAlpha and if they both fail, reject the keypress.


使用Validating ^ ]或KeyDown事件,然后编写一个简单的正则表达式以仅接受字母.

检查此答案 [ ^ ] out.
Use the Validating event[^] or KeyDown event and then write a simple regular expression to accept only alphabets.

Check this answer[^] out.