JQuery input masks for entering date and time using US dates

I use Robin Herbot's excellent jQuery Input Masks plugin. [ https://github.com/RobinHerbots/jquery.inputmask ]. It is quite complete and seems to have everything I need, but I seem to be unable to understand anything.

How to create a mask, for example: "mm / dd / yyyy hh: mm pm" , where both the part of the date and the temporary part work, such as the "date" and "time" masks

I can use date or time, but datetime uses the European format dd / mm, not the mm / dd format that I need. I tried a few permutations, but I obviously missed something, and the documentation is taken for granted.

+4
source share
3 answers

jQuery Input Mask

$('#InputID').inputmask({
        mask: "2/1/y h:s t\\m",
        placeholder: "mm/dd/yyyy hh:mm xm",
        alias: "datetime",
        hourFormat: "12"
    });

Check other aliases.

+6
source

Go here: http://digitalbush.com/projects/masked-input-plugin/

Use this:

$('#InputID').mask("99/99/9999 99:99 aa");

Welcome.

+2
source

The Maskedinput plugin is the best solution for entering the date and time type - simple and easy.

As for "accepting any number": you can easily modify the base regular expression of js base by adding your own rules:

{ definitions: { 9: "[0-9]", 1: "[0-1]", 2: "[0-2]", a: "[A-Za-z]", "*": "[A-Za-z0-9]" }

0
source

Source: https://habr.com/ru/post/1523992/


All Articles