Conditional Phone masking Imask.js

499 Views Asked by At

I have below code :

var items = document.getElementsByClassName('phone-mask');

Array.prototype.forEach.call(items, function(element) {
    var phoneMask = new IMask(element, {
  mask: '000-0000-000',
  placeholder: {
    show: 'always'
  }
});
});

but I need to put conditional masking. For example if phone number starts from 0 then mask: '0000-0000-000' else if phone starts from any other digit then mask: '000-0000-000'. how can this be done ?

0

There are 0 best solutions below