regular expressions can be used to validate the input value.
The sample function below show how to check if the input
is valid time in XX:XX, code is in C#.
This regular expression checks the input for 00:00 to 23:59 is a valid time format.
Time regular expression used to control time is ^(20|21|22|23|[01]\d|\d)(([:][0-5]\d){1,2})$
using System.Text.RegularExpressions;
public bool IsValidTime(string thetime)
{
Regex checktime =
new Regex(@"^(20|21|22|23|[01]d|d)(([:][0-5]d){1,2})$");
return checktime.IsMatch(thetime);
}
Is valid time validation with regular expression in C#.