I have made this regex
^(00|0[0-9]|1[012]):[0-5][0-9]? ((a|p)m|(A|P)M)$
but the problem is it is accepting
00:00 am which i dont want to be like this
how to ignore?
I want time to be in this format
12:12 am
it should not be in this
00:21 am
I am using this code for validation
private bool valtime()
{
Regex regex = new Regex("^(00|0[0-9]|1[012]):[0-5][0-9]? ((a|p)m|(A|P)M)$");
if (regex.IsMatch(textBox1.Text))
{
return false;
}
else
{
return true;
}
}
You could use: