Javascript mask for time entry

3

Does anyone know of any javascript mask for input at times where the format is not HH: mm. I will use it to set the time in project hours and some of them can take more than 24h. Example 120: 00 hours, 200: 00 hours and thereafter. The masks I got were only for the 24h format.

    
asked by anonymous 12.04.2014 / 21:25

2 answers

5

I do not know if using jQuery-based plugins is an alternative to your project, but there is an excellent plugin for various types of masks: jquery.inputmask .

Then you could do something like this:

$('input').inputmask("99:99");

or format the mask the way you need it. This plugin also has many other interesting features.

    
12.04.2014 / 22:27
1

Using RegEx:

/^([0-9]?[0-9]?[0-9]):[0-5][0-9]$/

In this way you can validate the formats:

9:59 | 09:59 | 009:59 | 100:00 | 999:59
    
12.04.2014 / 22:11