简体   繁体   English

如何绑定国家更改国际电话输入

[英]how to bind country change intl tel input

I using country code plugin name intlTelInput.js (this I demo page) in the page I want to empty the phone (input filed) when country select change我在页面中使用国家代码插件名称intlTelInput.js (这个我的演示页面)我想在国家选择更改时清空电话(输入文件)

<div class="demo">
    <h3>Demo</h3>
    <div class="iti iti--allow-dropdown">
        <div class="iti__flag-container">
            <div class="iti__selected-flag" role="combobox" aria-owns="country-listbox" tabindex="0"
                title="Algeria (&#8235;الجزائر&#8236;&lrm;): +213">
                <div class="iti__flag iti__dz"></div>
                <div class="iti__arrow"></div>
            </div>
        </div><input type="tel" id="phone" class="form-control" autocomplete="off" data-intl-tel-input-id="0"
            placeholder="0551 23 45 67">
    </div>
</div>

I tried:我试过:

$(".iti__selected-flag").bind('change', function(event) {
         $('#phone').val('')
      });

And below code will make phone filed value empty (when click , but I want it empty when after select another country item done)下面的代码将使电话归档值为空(单击时,但在选择另一个国家/地区项目完成后我希望它为空)

$(function(){
      $("#phone").bind('change', function(event) {
         $('#phone').val('')
      });
    })

But it not working但它不起作用

There is a native way to bind country change intl-tel-input :有一种本地方法可以绑定国家/地区更改intl-tel-input

var input = $("#phone");
input.intlTelInput();

input.on("countrychange", function() {
  input.val('')
});
var input = document.querySelector("#phone1");        
   window.intlTelInput(input, {        
     initialCountry: "In", //change according to your own country.      
     utilsScript: "assets/js/utils.js",        
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用ng-intl-tel-input指令获取国家/地区代码 - How to get country code with ng-intl-tel-input directive 如何从(国际电话输入)jquery 获取国家/地区 - How to get country from (intl-tel-input) jquery 如何从 intl-tel-input 中删除国家/地区 - How to remove a country from intl-tel-input 如何从国际电话输入中获取国家/地区价值? - How to get country value from intl-tel-input? 在国际电话输入中获取带有国家代码(拨号代码)的完整号码 - Get full number with country code(dial code) in intl tel input 如何集成 react-intl-tel-input - How to integrate react-intl-tel-input 使用 jquery [auto country by IP/intl-tel-input jquery library] 获取国家代码的输入值 - Get input value for country code with jquery [auto country by IP/intl-tel-input jquery library] 来自另一个下拉菜单的国际电话输入更改下拉菜单拨号代码 - Intl tel input change dropdown dialcode from another dropdown 在国家/地区代码下拉列表中添加所需的验证[intl-tel-input jquery plugin] - Add required validation on country code drop down [ intl-tel-input jquery plugin ] 尝试将国际电话输入库用于国家代码时出错 - Got error while try to use intl-tel-input liberary for country code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM