检查在文本框中输入的文本格式

编程入门 行业动态 更新时间:2024-10-27 00:31:46
本文介绍了检查在文本框中输入的文本格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我要检查单击按钮时在文本框中输入的文本. 格式应为以下XXXX-XXXX(2012-2013). 提前thx ....

I want to check text entered in textbox on button click. The Format Should be like this XXXX-XXXX(2012-2013). thx in advance ....

推荐答案

最好使用MaskedTextBox: 已屏蔽的C#TextBox控件 [ ^ ] msdn.microsoft/en-us/library/kkx4h3az.aspx [ ^ ] 但是,如果您不使用MaskedTextBox,则可以执行以下操作: www.dotnetperls/regex-match [ ^ ] msdn.microsoft/en-us/library/twcw2f1c.aspx [ ^ ] oreilly/windows/archive/csharp-regular-expressions.html [ ^ ] www.radsoftware.au/articles/regexlearnsyntax.aspx [ ^ ] Better u use MaskedTextBox : Masked C# TextBox Control[^] msdn.microsoft/en-us/library/kkx4h3az.aspx[^] But if u don''t use MaskedTextBox u can do following: www.dotnetperls/regex-match[^] msdn.microsoft/en-us/library/twcw2f1c.aspx[^] oreilly/windows/archive/csharp-regular-expressions.html[^] www.radsoftware.au/articles/regexlearnsyntax.aspx[^]

您可以为此使用MaskedTextBox 您可以在此处找到各种遮罩字符并在MaskedTextBox上提供帮助 msdn.microsoft/en-us/library/system.windows.forms.maskedtextbox.mask.aspx [ ^ ] 另一种选择是检查像这样的正则表达式 You can use MaskedTextBox for this purpose You can find the various mask characters and help on MaskedTextBox here msdn.microsoft/en-us/library/system.windows.forms.maskedtextbox.mask.aspx[^] Other option is to check with regular expressions like this Regex.IsMatch(TextBox1.Text,@"[A-Z]{4}\-[A-Z]{4}\(2012\-2013\)")

如果您的问题得到解决,则可以接受该解决方案,否则,请发布您的查询

If your problem is solved, you may accept the solution otherwise please post your queries

更多推荐

检查在文本框中输入的文本格式

本文发布于:2023-10-15 01:24:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1492827.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本   框中输入   格式

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!