Jquery输入掩码“dd-mm-yyyy hh:mm”

时间:2017-11-29 13:05:53

标签: jquery datetime jquery-inputmask

如何配置以实现“dd-mm-yyyy hh:mm”格式?

$('input').inputmask({
                mask: "1-2-y h:s",
                placeholder: "dd-mm-yyyy hh:mm",
                leapday: "29-02-",
                separator: "-",
                alias: "dd-mm-yyyy"
            });

这不起作用,它显示“dd-mm-yyyy h:s”,我只能编辑“dd-mm-yyyy”。

inputmask

https://jsfiddle.net/re4qxxr1/

3 个答案:

答案 0 :(得分:4)

试试这会对你有所帮助:

$('input').inputmask("datetime",{
     mask: "1-2-y h:s", 
     placeholder: "dd-mm-yyyy hh:mm", 
     leapday: "-02-29", 
     separator: "-", 
     alias: "dd-mm-yyyy"
});

小提琴:https://jsfiddle.net/53nomjyb/193/

答案 1 :(得分:0)

终于得到了答案,Link我得到了答案 https://github.com/RobinHerbots/Inputmask/issues/727

(function($){ 
  $('input').inputmask("datetime",{
    mask: "1-2-y h:s", 
    placeholder: "dd-mm-yyyy hh:mm", 
    leapday: "-02-29", 
    separator: "-", 
    alias: "dd/mm/yyyy"
  });
  
})(jQuery)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://rawgit.com/RobinHerbots/jquery.inputmask/3.x/dist/jquery.inputmask.bundle.js"></script>
<input type="text">

答案 2 :(得分:0)

如果您使用的是Inputmask 4。*:

    Inputmask("datetime", {
        inputFormat: "dd-mm-yyyy HH:MM",
        placeholder: "_",
        leapday: "-02-29",
        alias: "tt.mm.jjjj"
    }).mask(".my-fields-to-mask");