$("input[name='phone']").mask("+7 (999) 999-99-99");
$.mask.definitions['~']='[78]';
$("[name=phone]").mask("~ (999) 999-9999");
var customOptions = {
onKeyPress: function(val, e, field, options) {
if (val.replace(/\D/g, '').length===2)
{
val = val.replace('8','');
field.val(val);
}
field.mask("+7 (999) 999-99-99", options);
},
placeholder: "+7 (___) ___-__-__"
};
$("input[name='phone']").mask("+7 (999) 999-99-99", customOptions);