Advertisement
bongzilla

Untitled

Jul 8th, 2022
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. //masks
  2. function initPhoneMask(fieldId) {
  3.  
  4. $(fieldId).attr("maxlength", "14");
  5.  
  6. $.mask.definitions['9']='';
  7. $.mask.definitions['d']='[0-9]';
  8. $(fieldId).mask("+7 (ddd) ddd-dd-dd");
  9. let itiInstance = $(fieldId).intlTelInput({
  10. utilsScript:'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.13/js/utils.min.js',
  11. defaultCountry: 'auto',
  12. autoHideDialCode:false,
  13. autoPlaceholder:"aggressive",
  14. placeholderNumberType:"MOBILE",
  15. preferredCountries:['ru','by', 'kz', 'am', 'kg'],
  16. separateDialCode:true,
  17. customPlaceholder:function(selectedCountryPlaceholder,selectedCountryData){
  18. return '+'+selectedCountryData.dialCode+' '+selectedCountryPlaceholder.replace(/[0-9]/g,'_');
  19. },
  20. });
  21. $(fieldId).on("close:countrydropdown",function(e,countryData){
  22. $(this).val('');
  23. $(this).mask($(this).attr('placeholder').replace(/[_]/g,'d'));
  24. });
  25.  
  26. return itiInstance
  27. }
  28.  
  29. $(".formPhone").each(function(){
  30. let iti = initPhoneMask($(this));
  31. console.log("iti", iti);
  32. console.log("currentCode", ___INTL_TEL_INPUT_CURRENT_COUNTRY);
  33. iti.intlTelInput("setCountry", ___INTL_TEL_INPUT_CURRENT_COUNTRY);
  34. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement