我想用intlTelInput
库进行的验证将数字电话输入放入订阅表中,这是我的代码:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="flags.min.css">
<link rel="stylesheet" type="text/css" href="css2.css">
<link rel="stylesheet" type="text/css" href="bootstrap-social.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="build/css/intlTelInput.css">
<script src="google/jquery-1.11.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<div class="container">
<div class="row flex-grow">
<div class="col-xs-offset-1 col-xs-10 col-lg-12 col-lg-offset-0">
<div class="row" id="grad1">
<br>
<div class="col-xs-offset-1 col-xs-10 col-lg-offset-4 col-lg-4">
<form method="post" action="serv2.php" onsubmit="return submitForm(this);">
<fieldset>
<div class="row">
<div class="form-group phone">
<input type="tel" class="form-control" id="phone" name="phone" placeholder="Phone number" />
</div>
<div class="form-group country">
<input type="text" id="country" name="country" class="form-control" placeholder="Country" />
</div>
<div class="form-group col-lg-6 col-lg-offset-3">
<div>
<label for="bouton"><br></label>
<div>
<button type="submit" class="btn btn-default" style="background-color: #00B0F0; color:white; width: 100%;border:none;">Valider</button>
</div>
</div>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
</div>
</html>
</body>
<script src="build/js/intlTelInput.min.js"></script>
<script>
$("#phone").intlTelInput({
initialCountry: "auto",
geoIpLookup: function(callback) {
$.get('https://ipinfo.io', function() {}, "jsonp").always(function(resp) {
var countryCode = (resp && resp.country) ? resp.country : "";
callback(countryCode);
});
},
utilsScript: "build/js/utils.js"
});
var telInput = $("#phone"),
errorMsg = $("#error-msg"),
validMsg = $("#valid-msg");
telInput.intlTelInput({
utilsScript: "build/js/utils.js"
});
</script>
问题在于,电话输入不能像国家一样采用表格的整个宽度。
我试图用
document.getElementById('phone').style.minWidth = 100%;
进行更改,但它删除了intlTelInput
库的操作(即不再显示标志图标)。任何的想法 ?
谢谢
最佳答案
好的,我最终找到了答案,它在文档中,只需要将类intl-tel-input{width: 100%;}
添加到容器中
关于jquery - Bootstrap:为什么intlTelinput更改输入元素的宽度?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44418593/