Community Patterns

Community Library Entry

1

Regular Expression
Created·2022-01-25 14:51
Updated·2022-01-25 15:05
Flavor·ECMAScript (JavaScript)

/
^(0\d|1\d|2[0-4]):(0\d|[1-5]\d)(?::(0\d|[1-5]\d))?(?:.(00\d|0[1-9]\d|[1-9]\d{2}))?$
/
gm
Open regex in editor

Description

As 'time' input doesn't have a [pattern] attribute, you can check its value with this RegExp.

You must provide hours and minutes. Seconds and milliseconds are optional.

To "activate" seconds on the input, give it the step="" attribute with a number reprensenting the incrementation in seconds.

To "activate" milliseconds on the input, set the step attribute to "0.001"

Submitted by Ann MB