如何只允许在带遮罩的文本框中显示字母 [英] How to allow only alphapets in a masked text box

查看:80
本文介绍了如何只允许在带遮罩的文本框中显示字母的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表单中使用蒙版文本..我只允许在蒙版文本框中使用字母..我验证了文本框只允许将字母作为普通文本框使用,但允许数字使用..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 此答案 [ ^ ] out.
Use the Validating event[^] or KeyDown event and then write a simple regular expression to accept only alphabets.

Check this answer[^] out.


这篇关于如何只允许在带遮罩的文本框中显示字母的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆