Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to validate time text box in c#.net?
Posted

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.
 
Share this answer
 
May I suggest to use a DateTimePicker instead? It is simpler and easier to use by you and by the user.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900