24 hour time regex for HTML 5


Wanted to Inquire about the possible Regex expression for 24-hour time format in HTML 5 (HH:MM) .

if possible, kindly tell the regex that can be used in the Pattern attribute of HTML 5

The time is expected to be in 24-hour format (HH not more than 23).

Kind regards,


I think this is a possible approach :

<input type="text" pattern="([01]?[0-9]|2[0-3]):[0-5][0-9]" id="24h"/>
<input type="text" pattern="([01]?[0-9]{1}|2[0-3]{1}):[0-5]{1}[0-9]{1}" id="24h"/>



Check out this jsfiddle : example

Answered By – radu florescu

Answer Checked By – David Marino (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.