Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //masks
- function initPhoneMask(fieldId) {
- $(fieldId).attr("maxlength", "14");
- $.mask.definitions['9']='';
- $.mask.definitions['d']='[0-9]';
- $(fieldId).mask("+7 (ddd) ddd-dd-dd");
- let itiInstance = $(fieldId).intlTelInput({
- utilsScript:'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.13/js/utils.min.js',
- defaultCountry: 'auto',
- autoHideDialCode:false,
- autoPlaceholder:"aggressive",
- placeholderNumberType:"MOBILE",
- preferredCountries:['ru','by', 'kz', 'am', 'kg'],
- separateDialCode:true,
- customPlaceholder:function(selectedCountryPlaceholder,selectedCountryData){
- return '+'+selectedCountryData.dialCode+' '+selectedCountryPlaceholder.replace(/[0-9]/g,'_');
- },
- });
- $(fieldId).on("close:countrydropdown",function(e,countryData){
- $(this).val('');
- $(this).mask($(this).attr('placeholder').replace(/[_]/g,'d'));
- });
- return itiInstance
- }
- $(".formPhone").each(function(){
- let iti = initPhoneMask($(this));
- console.log("iti", iti);
- console.log("currentCode", ___INTL_TEL_INPUT_CURRENT_COUNTRY);
- iti.intlTelInput("setCountry", ___INTL_TEL_INPUT_CURRENT_COUNTRY);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement