openclassify/addons/default/visiosoft/profile-module/resources/assets/js/profile.js
2020-02-25 12:05:17 +03:00

32 lines
1.1 KiB
JavaScript

// Personal Registration
var inputQueries = document.querySelectorAll("input[name='gsm_phone'],input[name='office_phone'],input[name='land_phone']");
inputQueries.forEach(function (inputQuery, key) {
var iti = intlTelInput(inputQuery, {
hiddenInput: "full_phone_" + inputQuery.getAttribute('name'),
class: "form-control",
initialCountry: "auto",
geoIpLookup: function (success, failure) {
$.get("https://ipinfo.io", function () {
}, "jsonp").always(function (resp) {
var countryCode = (resp && resp.country) ? resp.country : "";
success(countryCode);
})
}
})
});
maskPhone('gsm_phone')
maskPhone('land_phone')
maskPhone('office_phone')
$("input[name='gsm_phone'],input[name='office_phone'],input[name='land_phone']").on('countrychange', function (e) {
maskPhone($(this).attr('name'))
});
function maskPhone(name) {
var currentMask = $("input[name='" + name + "']").attr('placeholder');
$("input[name='" + name + "']").mask(currentMask.replace(/[0-9+]/ig, '9'), {
autoclear: true,
clearIncomplete: true
});
}