我如何从蒙版文本框中验证数字? [英] How can i validate numeric numbers from masked textbox?
本文介绍了我如何从蒙版文本框中验证数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
先生,
先生,请帮助我,我该如何在Windows应用程序中从蒙版文本框(仅允许字母)验证数字和特殊字符!!
解决方案
具有RegularExpressionValidator
带有正确的正则表达式来验证textbox
.
但是,如果您的要求是只允许MaskedTextBox
中的字母,那么我认为您可以考虑使用掩码字符吗?在Mask属性中
MaskedTextBox1.Mask = " ;
这 ? charcater允许
字母,可选.将输入限制为ASCII字母a-z和A-Z.此蒙版元素等效于[a-zA-Z]?在正则表达式中.如此处所述.
MaskedTextBox的Mask属性的蒙版元素 [ ^ ]
我在互联网上进行了搜索,发现了此 [ ^ ],也许对您有用.
HI sir,
please help me sir, How can i validate numeric numbers and special characters from Masked Text Box(Allow only Alphabets)in windows Application !!
解决方案
Have aRegularExpressionValidator
with proper regular expression validating thetextbox
.
But if your requirement is to allow only alphabet in theMaskedTextBox
then I think you can consider using mask character ? in the Mask property
MaskedTextBox1.Mask = "???????";
The ? charcater allows a
Letter, optional. Restricts input to the ASCII letters a-z and A-Z. This mask element is equivalent to [a-zA-Z]? in regular expressions. as explained here.
Mask elements for Mask property of MaskedTextBox[^]
I did a search on the internet and found this[^], maybe it will be useful to you.
这篇关于我如何从蒙版文本框中验证数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文