简体   繁体   English

没有从 intlTelInput 输入中获取国家代码

[英]not getting Country code from intlTelInput input

In my Laravel project, I am using intlTelInput for getting the country code input field.在我的 Laravel 项目中,我使用 intlTelInput 获取国家代码输入字段。 I am getting the country code and country flags (readonly).我正在获取国家代码和国旗(只读)。 But when I submit form I am getting only the text field value but not getting the country code merging with it.但是当我提交表单时,我只得到文本字段值,但没有得到国家代码与其合并。 like I select Bangladesh.像我 select 孟加拉国。 the beside the flag is shows- 880 in the read-only field.标志旁边是只读字段中的 shows- 880。 after that then I put the rest of the number in the editable text field like: 171111111 and submit the result I am getting is 17111111. I am not getting the country code merged result like 8801711111111. What to do?之后,我将数字的 rest 放入可编辑文本字段中,例如:171111111 并提交我得到的结果是 17111111。我没有得到国家代码合并结果,例如 8801711111111。怎么办?

blade.php part: blade.php部分:

<input id="phone" class="form-control" name="client_phone1" type="tel" />

script part:脚本部分:

<script>
  var input = document.querySelector("#phone");
  window.intlTelInput(input, {
    // allowDropdown: false,
    // autoHideDialCode: false,
    autoPlaceholder: "off",
    // dropdownContainer: document.body,
    // excludeCountries: ["us"],
    // formatOnDisplay: false,
    // geoIpLookup: function(callback) {
    //   $.get("http://ipinfo.io", function() {}, "jsonp").always(function(resp) {
    //     var countryCode = (resp && resp.country) ? resp.country : "";
    //     callback(countryCode);
    //   });
    // },
    // hiddenInput: "full_number",
    // initialCountry: "auto",
    // localizedCountries: { 'de': 'Deutschland' },
    // nationalMode: false,
    // onlyCountries: ['us', 'gb', 'ch', 'ca', 'do'],
    placeholderNumberType: "MOBILE",
    preferredCountries: ["bd"],
    separateDialCode: true,
    utilsScript: "public/build/js/utils.js"
  });
</script>

add in variable添加变量

var iti= window.intlTelInput(input, {
    // allowDropdown: false,
    // autoHideDialCode: false,
    autoPlaceholder: "off",
    // dropdownContainer: document.body,
    // excludeCountries: ["us"],
    // formatOnDisplay: false,
    // geoIpLookup: function(callback) {
    //   $.get("http://ipinfo.io", function() {}, "jsonp").always(function(resp) {
    //     var countryCode = (resp && resp.country) ? resp.country : "";
    //     callback(countryCode);
    //   });
    // },
    // hiddenInput: "full_number",
    // initialCountry: "auto",
    // localizedCountries: { 'de': 'Deutschland' },
    // nationalMode: false,
    // onlyCountries: ['us', 'gb', 'ch', 'ca', 'do'],
    placeholderNumberType: "MOBILE",
    preferredCountries: ["bd"],
    separateDialCode: true,
    utilsScript: "public/build/js/utils.js"
  });

get like this变得像这样

iti.getSelectedCountryData().iso2,

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM