Inputmask: Regex fot time HH:MM 24Hours

Created on 17 Dec 2014  路  11Comments  路  Source: RobinHerbots/Inputmask

Hello i try to to a mask for hour format but i can't able to use regex.
i try to instances this component with this line:

$("#time_apertura").inputmask({"mask":"99:99","regex":"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$"});
mask work fine, but regex don't work.
can you help me to solve my problem? in next time you could add this issue in documentation.

thank you very much
Valerio Radice
Valix85

Dates

Most helpful comment

@valix85 ,

If you want to use a regex then you need to use the regex extension. But in that case you do not have a visual mask.

Better use the hh:mm alias.
$("#time_apertura").inputmask("hh:mm");

All 11 comments

@valix85 ,

If you want to use a regex then you need to use the regex extension. But in that case you do not have a visual mask.

Better use the hh:mm alias.
$("#time_apertura").inputmask("hh:mm");

Thank you for your reply, tomorrow i try it.
it's possible have an example that use same regex indicate in my regex?
i don't understand if you use a standard regex or if you use your property sintax regex...

thanks

$("#time_apertura").inputmask({"alias":"Regex","regex":"^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$"});

Ok thank you very much. Your method work fine than my regex ;)

Issue close.

Should I include regex extension apart from input mask bundle?

@sonusasankan ,

No you don't need to , but in version 3.x the regex support is through an alias Regex, while in version 4.x support is 'native' (without alias extension)

In v3.11 you add alias: "Regex", regex: "your regex"
in v4.x you only add regex: "your regex"

@RobinHerbots

How could I add 0 dynamically when onblur if user input only hour?

@sonusasankan ,

Use the onBeforeWrite callback. Have a look at the other extensions, for some example.

This is almost 2 years old now, but the example doesn't work for me even though it works on that fiddle.

This is almost 2 years old now, but the example doesn't work for me even though it works on that fiddle.

@Healyhatman,

Can you open a new issue and describe your problem and give an example.

@RobinHerbots It's my bad sorry. I was trying to call it with
$(selector).inputmask({'alias':'datetime', 'inputFormat':'HH:MM'})
instead of
Inputmask('datetime', {'inputFormat':'HH:MM'}).mask(selector)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

toxpal picture toxpal  路  6Comments

ErikPham picture ErikPham  路  5Comments

osaris picture osaris  路  6Comments

blaskognia picture blaskognia  路  5Comments

RipDevil picture RipDevil  路  5Comments