简体   繁体   English

为电话号码选择国家/地区代码时,如何将土耳其设为默认国家/地区?

[英]How can I make Turkey the default country when choosing a country code for a phone number?

This script allows me to pick country code when I want to write my number:当我想写我的号码时,这个脚本允许我选择国家代码:

const phoneInputField = document.querySelector("#inpMobilePhone");
const phoneInput = window.intlTelInput(phoneInputField, {
    utilsScript:
        "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js",
    });
}

This html is my phone input and the reason type=number because when I change that to type=tel it's allows me to write text to:这个 html 是我的电话输入,原因type=number因为当我将其更改为type=tel时,它允许我将文本写入:

<div class="form-group">
    <input type="number" pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}" style="width:168%" 
        class="form-control form-control-sm" placeholder="@localizer["MobilePhone"]" 
        id="inpMobilePhone" name="MobilePhone" required />
</div>

This is the first thing i saw i want to change this:这是我看到的第一件事,我想改变它:

在此处输入图像描述

Check the initialCountry option from the documentation of intel-tel-input library.从 intel-tel-input 库的文档中检查initialCountry选项。

Set the initial country selection by specifying its country code.通过指定国家代码来设置初始国家选择。

const phoneInput = window.intlTelInput(phoneInputField, {
    initialCountry: "TR",
    utilsScript:
        "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js",
    });

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

相关问题 如何使用正则表达式验证电话号码中的国家/地区代码 - How to make regex that validate country code in phone number 如何区分国家/地区代码形式的电话号码? - How to separate country code form Phone number? 如何用电话号码保存国家代码? - How to save country code with phone number? 如何仅通过查看数字来确定国家/地区代码 - How can i determine the country code just by looking at the number 如何分别获取国家代码和电话号码并根据javascript中的国家代码验证ph号码的长度? - How to get country code and phone number separately and validate length of the ph number based on country code in javascript? 如何通过按单独的选项列表选择国家/地区,在电话字段中添加国家/地区电话号码 - How can i add country phone number in phone field by selecting countries by separate option list 如何使用正则表达式使用国家/地区代码格式化手机号码 - How to format mobile phone number with country code using regex 如何在 React JS 中使用国家代码进行电话输入 - How to make phone input with country code in React JS 根据国家/地区代码验证电话号码 - Validating Phone Number based on country code 使用 intlTelInput 验证带有国家代码的电话号码 - Validation phone number with country code using intlTelInput
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM