RobinHerbots / Inputmask

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

How can I add multiple masks on input #1944

Open fictioN89 opened 6 years ago

fictioN89 commented 6 years ago

Hello Robin,

I'm trying to add multiple masks on some inputs, the masks should be: 1 - HH:MM with hours and minutes in 24 format 2 - BO 3 - I

I've tried with this code but i can't manage to do the regex function for the 24 format, the user can put for example a 25:99 in a time input.

jQuery('input.hours-begin').inputmask({ mask: ["99:99", "BO", "bo", "I"], definitions: { "99:99": { validator: function() { var valExp3 = new RegExp("([01]?[0-9]|2[0-3]):[0-5][0-9]"); return valExp3; } }, "BO": { validator: "[BO]", casing: "upper" }, "bo": { validator: "[bo]", casing: "upper" }, "I": { validator: "[iI]", casing: "upper" } } });

RobinHerbots commented 6 years ago

@fictioN89 ,

A definition is always a single character.

But you can try with a regex mask

`` Inputmask({ regex: "([01][0-9]|2[0-3]:[0-5][0-9])|([Bb][Oo])|[Ii]", casing: "upper" }).mask("test1");