J
Jim in Arizona
I set up a regular expression validator on my web form to make sure
users were putting in correct time format but I can't seem to get it right.
The problem is that I need them to input a time based on the 12 hour
clock. This regular expression works fine:
^([0-1][0-2])[0-5][0-9])$
However, this does not include AM or PM designators and this is where I
can't seem to find the proper expression. I have tried this:
^([0-1][0-2])[0-5][0-9]):b([AM]|[am]|[PM]|[pm])$
That one doesn't work. I even tried making it as simple as possible just
for testing purposes, like so:
^([0-1][0-2])[0-5][0-9])([AM])$
or
^([0-1][0-2])[0-5][0-9])AM$
But, when I put in a time like 12:20AM or 12:20 AM, the validator is
triggered.
I'm hoping to avoid using a 24 hour clock as this would just cause
frustration for our secretaries.
TIA,
Jim
users were putting in correct time format but I can't seem to get it right.
The problem is that I need them to input a time based on the 12 hour
clock. This regular expression works fine:
^([0-1][0-2])[0-5][0-9])$
However, this does not include AM or PM designators and this is where I
can't seem to find the proper expression. I have tried this:
^([0-1][0-2])[0-5][0-9]):b([AM]|[am]|[PM]|[pm])$
That one doesn't work. I even tried making it as simple as possible just
for testing purposes, like so:
^([0-1][0-2])[0-5][0-9])([AM])$
or
^([0-1][0-2])[0-5][0-9])AM$
But, when I put in a time like 12:20AM or 12:20 AM, the validator is
triggered.
I'm hoping to avoid using a 24 hour clock as this would just cause
frustration for our secretaries.
TIA,
Jim