4

I want to implement simple jquery mask pluging using jquery input.mask plugin, however, i cannot make it work with regex. What i want to achieve is:

99:59:59

Fiddle

3 Answers 3

9

You can do it like this.

$("#test").inputmask({
            mask: "99:59:59",
            definitions: {'5': {validator: "[0-5]"}}
    });

The validator is an expression. Telling the "5" in the mask string to contain only numerical characters from 0 to 5.

edit: changed '-' to ':'

Sign up to request clarification or add additional context in comments.

Comments

3

You mean something like this:

$('#test').inputmask('Regex', { 
    regex: "^[0-9]{2}:[0-5][0-9]:[0-5][0-9]$"
});

1 Comment

the only problem is Regex extension does not support placeholder, but for simple masks adding definitions as in @Buster response does. Using Regex as you suggest provides validation only.
0

use

<script src="../js/jquery.inputmask.bundle.js"></script>

 <asp:TextBox class="form-control" ID="trvl_amt" data-inputmask="'mask': '9{0,50}.9{0,2}'" data-mask placeholder="Travel Amount"  runat="server"></asp:TextBox>

Up to 50 numeric places + 2 Decimal

1 Comment

any values between 50 numeric places and 2 Decimal Places

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.