Подключение:
<script src="https://cdn.jsdelivr.net/npm/jquery@3.6.1/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/imask@6.4.3/dist/imask.min.js"></script>
Разметка:
<input type="text" placeholder="Телефон" class="js-phone">
<input type="text" placeholder="Цена" class="js-price">
<input type="text" placeholder="DD.MM.YYYY" class="js-date">
Инициализация:
$(".js-price").each(function () {
IMask(this, {
mask: Number,
min: 0,
thousandsSeparator: " ",
});
});
$(".js-phone").each(function () {
IMask(this, {
mask: "+{7}(000)000-00-00",
});
});
$(".js-date").each(function () {
IMask(this, {
mask: Date,
});
});
$(".js-number").each(function () {
const min = $(this).data("min") || -Infinity;
const max = $(this).data("max") || Infinity;
IMask(this, {
mask: Number,
min,
max,
});
});
0 комментариев