$(document).ready(function() {
var phoneInputID = "input#phone";
var input = document.querySelector(phoneInputID);
var iti = window.intlTelInput(input, {
formatOnDisplay: true,
hiddenInput: "full_number",
preferredCountries: ['ua'],
});
$(phoneInputID).on("countrychange", function(event) {
// Get the selected country data to know which country is selected.
var selectedCountryData = iti.getSelectedCountryData();
// Get an example number for the selected country to use as placeholder.
newPlaceholder = intlTelInputUtils.getExampleNumber(selectedCountryData.iso2, true, intlTelInputUtils.numberFormat.INTERNATIONAL),
// Reset the phone number input.
iti.setNumber("");
// Convert placeholder as exploitable mask by replacing all 1-9 numbers with 0s
mask = newPlaceholder.replace(/[1-9]/g, "0");
// Apply the new mask for the input
$(this).mask(mask);
});