Text-mask: How to implement time mask in 24h format

Created on 2 Apr 2017  路  3Comments  路  Source: text-mask/text-mask

i need to force input to enter time in 24h format
sample
23:40 -- and force only connect number i tried with regular expression but it does not work

question

Most helpful comment

You could use a mask something like [/[0-2]/, /[0-9]/, ':', /[0-5]/, /[0-9]/] might do the trick. But its not perfect as it allows values like 25:00. You could take a look at the createAutoCorrectedDatePipe addon and maybe adapt that to work with times.. shouldn't be too difficult.

All 3 comments

You could use a mask something like [/[0-2]/, /[0-9]/, ':', /[0-5]/, /[0-9]/] might do the trick. But its not perfect as it allows values like 25:00. You could take a look at the createAutoCorrectedDatePipe addon and maybe adapt that to work with times.. shouldn't be too difficult.

as i mention before i used the same [/[0-2]/, /[0-9]/, ':', /[0-5]/, /[0-9]/] but i need more friendly experience look like i have to use createAutoCorrectedDatePipe

Also, user could enter "9:20" instead of "09:20", how deal with that?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

msafi picture msafi  路  7Comments

intellix picture intellix  路  4Comments

kenpeter picture kenpeter  路  3Comments

refo picture refo  路  6Comments

ktriek picture ktriek  路  3Comments