Jquery国际电话号码输入 [英] Jquery International Telephone number input
问题描述
我正在尝试关注 http://www.jqueryscript.net/form/jQuery-International-Telephone-Input-With-Flags-Dial-Codes.html 使用表单中的国家/地区代码创建输入类型编号。但是,在我的情况下,虽然标志似乎发生了变化,但国家代码并未添加到输入字段中,因为它们在演示中显示。
I am trying to follow jquery tutorial on http://www.jqueryscript.net/form/jQuery-International-Telephone-Input-With-Flags-Dial-Codes.html to create input type number with country code in a form. However, in my case though flag is appearing to change, the country code is not added inside the input field as they show in the demo.
以下是他们提供的代码:
Following is the code they have provided:
<head>
<meta charset="utf-8">
<title>International Telephone Input</title>
<link rel="stylesheet" href="build/css/intlTelInput.css">
<link rel="stylesheet" href="build/css/demo.css">
</head>
<body>
<form>
<input id="mobile-number" type="tel">
<button type="submit">Submit</button>
</form>
<!-- Load jQuery from CDN so can run demo immediately -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="build/js/intlTelInput.js"></script>
<script>
$("#mobile-number").intlTelInput({
//allowExtensions: true,
//autoFormat: false,
//autoHideDialCode: false,
//autoPlaceholder: false,
//defaultCountry: "auto",
//ipinfoToken: "yolo",
//nationalMode: false,
//numberType: "MOBILE",
//onlyCountries: ['us', 'gb', 'ch', 'ca', 'do'],
//preferredCountries: ['cn', 'jp'],
//preventInvalidNumbers: true,
utilsScript: "lib/libphonenumber/build/utils.js"
});
</script>
这是我试图实现它的链接: https://www.easyaccom.com/mobile/verifynumber .html
Here is the link where I am trying to implement it: https://www.easyaccom.com/mobile/verifynumber.html
我尝试更改脚本中已注释掉的选项,但它没有帮助。
I have tried changing the commented out options in script but it doesn't help.
推荐答案
好的我解决了这个问题。
所以基本上这里的选项字段必须为true,我们需要在< / head>
标记之前放置以下脚本。
Ok I solved this problem.
So basically here are the option fields that must be true and we need to place the below script before </head>
tag.
脚本:
<script>
$(function() {
$("#mobile-number").intlTelInput({
allowExtensions: true,
autoFormat: false,
autoHideDialCode: false,
autoPlaceholder: false,
defaultCountry: "auto",
ipinfoToken: "yolo",
nationalMode: false,
numberType: "MOBILE",
//onlyCountries: ['us', 'gb', 'ch', 'ca', 'do'],
//preferredCountries: ['cn', 'jp'],
preventInvalidNumbers: true,
utilsScript: "lib/libphonenumber/build/utils.js"
});
});
</script>
在关闭head标签之前放置它并记得打电话给 $(#mobile -number)。intlTelInput();
因为它很重要。
Place it before closing head tag and remember to call $("#mobile-number").intlTelInput();
as it is important.
这篇关于Jquery国际电话号码输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!