如何在c#.net中验证时间文本框? [英] How to validate time text box in c#.net?
本文介绍了如何在c#.net中验证时间文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在c#.net中验证时间文本框?
How to validate time text box in c#.net?
推荐答案
使用正则表达式!
在对文本框进行聚焦或要根据需要进行任何其他事件验证时,使用正则表达式检查文本框中的文本,看其是否有效.
如果采用的是特定格式:0-24小时格式,那么您甚至可以直接检查小时,分钟,秒的范围,因为它并不那么复杂.
Use Regular Expression!
On focusout of textbox or any other event based on your need when you want to verify, check the text in the textbox with a regular expression and see if it''s a valid one or not.
If it''s in a particular format: 0-24 hours format, then you can even directly check for the hour, minute, second range as it''s not that complicated.
我可以建议改用DateTimePicker
吗?您和用户使用起来更简单,更容易.
May I suggest to use a DateTimePicker
instead? It is simpler and easier to use by you and by the user.
这篇关于如何在c#.net中验证时间文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文