RobinHerbots / Inputmask

Input Mask plugin
https://robinherbots.github.io/Inputmask/
MIT License
6.39k stars 2.17k forks source link

Regex not working with OR option "|" #2176

Open jamesRUS52 opened 5 years ago

jamesRUS52 commented 5 years ago

Uncaught Inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. (\d{2,}:\d{2}|\d{2,}:\d{2}:\d{2})

I also tried use another regex

Inputmask.extendAliases({ 'interval': { regex: "\d{2,}:\d{2}(:\d{2})?", onincomplete : function(){$(this).css("background-color",BadColor);}, oncomplete : function(){$(this).css("background-color",GoodColor);} } });

but it does not work also with input "12:00:2" This input is wrong, but regex match it

Please complete the following information:

RobinHerbots commented 4 years ago

@jamesRUS52 ,

Is the extra komma after the first \d{2,} intentional?

    Inputmask({
            regex: "\\d{2}:\\d{2}(:\\d{2})?"
            }
        ).mask("test2");
jamesRUS52 commented 4 years ago

Yes, two or more digits 10:02:02 10:02 123:02:02 123:02 1234:02:02 1234:02 I want to make time interval Total hours:minute and may be or not with :seconds

RobinHerbots commented 4 years ago

@jamesRUS52 ,

When using

Inputmask({
    regex: "\\d{2,}:\\d{2}(:\\d{2})?"
    }).mask("test2");

What exactly goed wrong?

jamesRUS52 commented 4 years ago

for value

03:00:1
console.log($('#test2').inputmask('isComplete'));

return True, but is not correct because we need exact two digits in third segment if it present