【问题标题】:Robin Herbots jquery.inputmask allow many values comma separatedRobin Herbots jquery.inputmask 允许许多值以逗号分隔
【发布时间】:2019-10-17 10:40:44
【问题描述】:

我有这个设置,效果很好:

$('#PhoneNumber').inputmask({ mask: "89999999999", placeholder: "" });

它允许输入以“8”开头的电话号码。但现在我希望它能够接受许多以逗号分隔的电话号码。

81234567890               -- rorrect
81234567890, 80987654321  -- rorrect
81234567890,80987654321   -- rorrect
81234567890,              -- not correct
81234567890,,             -- not correct
81234567890, 80987654321, -- not correct

             ...and so on...

This is the plugin我用过。

【问题讨论】:

    标签: javascript jquery formatting jquery-inputmask input-mask


    【解决方案1】:

    您可以将正则表达式模式与表达式 ^[0-9]{8}([,.][0-9]{8})+$ 一起使用:

    $('#phoneNumbers').inputmask({
      regex: "^[0-9]{8}([,.][0-9]{8})+$",
      placeholder: ""
    });
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://rawgit.com/RobinHerbots/jquery.inputmask/3.x/dist/jquery.inputmask.bundle.js"></script>
    <input id="phoneNumbers">

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-21
      • 2018-10-11
      • 1970-01-01
      • 1970-01-01
      • 2016-06-24
      • 1970-01-01
      相关资源
      最近更新 更多