最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Jquery input.mask with regex - Stack Overflow

programmeradmin6浏览0评论

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

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

Share Improve this question asked Dec 23, 2014 at 8:35 agribozagriboz 4,8544 gold badges36 silver badges49 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 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 ':'

You mean something like this:

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

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

发布评论

评论列表(0)

  1. 暂无评论