Home > database >  Validate time (h:mm) on Regex
Validate time (h:mm) on Regex

Time:07-29

I am validating h:mm and I need to have a max time 8:00.

Now the max value user can write is 7:59, but I need it to be 8:00.

My regex code: /^([0-8]|([0-7]|[2][0-3]):([0-5][0-9]))$/

CodePudding user response:

if I understand correctly, here is my solution: ^([0-7]:[0-5][0-9])|(8:00)$

  • Related