<script src="https://unpkg.com/imask"></script>
<input type="tel">
<input type="tel"><input type="tel"><input type="tel"><input type="tel"><input type="tel">
var items = document.querySelectorAll('input[type="tel"]');
items.forEach(function(el) {
var dispatchMask = new IMask(el, {
mask: [
{
mask: '+7 (000) 000-00-00',
startsWith: '7',
lazy: false,
country: 'Russia'
},
{
country: 'Azerbaijan',
mask: '+994 (00) 000-00-00',
lazy: false,
startsWith: '994'
},
{
country: 'Armenia',
mask: '+374 (00) 000-000',
lazy: false,
startsWith: '374'
},
{
country: 'Belarus',
mask: '+375 (00) 000-00-00',
lazy: false,
startsWith: '375'
},
{
country: 'Kazakhstan',
mask: '+7 (000) 000-00-00',
lazy: false,
startsWith: '7'
},
{
country: 'Kyrgyz',
mask: '+996 (000) 000-000',
lazy: false,
startsWith: '996'
},
{
country: 'Moldova',
mask: '+373 (000) 000-00',
lazy: false,
startsWith: '373'
},
{
country: 'Tajikistan',
mask: '+992 (00) 000-0000',
lazy: false,
startsWith: '992'
},
{
country: 'Uzbekistan',
mask: '+998 (00) 000-0000',
lazy: false,
startsWith: '998'
},
{
country: 'Ukraine',
mask: '+380 (00) 000-0000',
lazy: false,
startsWith: '380'
},
{
mask: '+(000) 000-00-00',
startsWith: '',
country: 'unknown'
}
],
dispatch: function (appended, dynamicMasked) {
var number = (dynamicMasked.value + appended).replace(/\D/g,'');
return dynamicMasked.compiledMasks.find(function (m) {
return number.indexOf(m.startsWith) === 0;
});
}
}
)
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.