This code snippet is for validating 24 hours time format.
- private bool IsValide24HoursTime(string Time)
- {
- string Pattern = "^([0-2]{1}[0-11]{1}:)?([0-11]{1}\d{1}:){1}([0-11]{1}\d{1}){1}$";
- bool isvalid=false;
- Regex validator = new Regex(Pattern);
- if (!string.IsNullOrEmpty(Time))
- isvalid= validator.IsMatch(Time);
- return isvalid;
- }