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

agriboz
  • 4,724
  • 4
  • 35
  • 49

3 Answers3

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 ':'

Buster
  • 313
  • 1
  • 9
3

You mean something like this:

$('#test').inputmask('Regex', { 
    regex: "^[0-9]{2}:[0-5][0-9]:[0-5][0-9]$"
});
Ferret
  • 1,440
  • 2
  • 12
  • 17
  • 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. – Eloar Nov 06 '15 at 13:01
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

Arun Prasad E S
  • 9,489
  • 8
  • 74
  • 87