gpt4 book ai didi

jquery - 如何修复 php 文件中的 bootstrapValidator 错误

转载 作者:太空宇宙 更新时间:2023-11-03 19:25:41 25 4
gpt4 key购买 nike

我无法使用 bootstrapValidation()

我制作了一个 php 文件,并在其中包含了 bootstrap 4.0 的所有 cdn,然后我制作了一个单独的 javaScript 文件,在那里我制作了一个 bootstrapValidtor 函数来检查输入长度,它使用 jQuery 和 Ajax 是空的,但它说未捕获的 ReferenceError:bootstrapValidator 未定义在 :1:1

<!DOCTYPE html>
<html>
<head>
<!-- included the CSS CDN of bootstrap 4.0.0-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<!-- online icons from fontawesome -->
<link href="https://use.fontawesome.com/releases/v5.6.1/css/all.css" rel="stylesheet" >

</head>
<body>
<div style="width: 50%; margin: 20px auto">
<form class="form needs-validation" action="" method="POST" id="contact-form" novalidate>

<div class="input-group mb-3 size">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-user"></i></span>
</div>
<input type="text" class="form-control" placeholder="First Name" name="first_name" required>
<div class="invalid-feedback">Please enter your First Name</div>
</div>

<div class="input-group mb-3 size">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-user"></i></span>
</div>
<input type="text" class="form-control" placeholder="Last Name" name="last_name" required>
<div class="invalid-feedback">Please enter your Last Name</div>
</div>

<button type="submit" class="btn btn-lg btn-primary text-align-center btn-block"><i class="fas fa-paper-plane"></i> Send</button>

</form>
</div>



<!-- This script is in external .js file -->
<script>
$(document).ready(function() {
//alert("HEllo Nehal");
$("#contact-form").bootstrapValidator({
feedbackIcons: {
// valid: 'glyphicon glyphicon-ok',
// invalid: 'glyphicon glyphicon-remove',
// validating: 'glyphicon glyphicon-refresh'
},
fields: {
first_name: {
validators: {
stringLength: {
min: 10,
message: "First Name should be at least 10 characters long"
},
notEmpty: {
message: "Please Enter Your First Name"
}
}
},
last_name: {
validators: {
stringLength: {
min: 10,
message: "Last Name should be at least 10 character long"
},
notEmpty: {
message: "please Enter your Last Name"
}
}
}
}
})
});

</script>

//external js file till here

<!-- for bootstrap validation -->
<script src="https://cdn.rawgit.com/PascaleBeier/bootstrap-validate/v2.2.0/dist/bootstrap-validate.js" ></script>

<!-- online javaScript CDN of bootstrap 4.0.0 -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>

</body>
</html>

最佳答案

请尝试此解决方案。

<head>
<!-- included the CSS CDN of bootstrap 4.0.0-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!-- online icons from fontawesome -->
<link href="https://use.fontawesome.com/releases/v5.6.1/css/all.css" rel="stylesheet" >
<!-- jQuery and Bootstrap JS -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<!-- BootstrapValidator JS -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery.bootstrapvalidator/0.5.0/js/bootstrapValidator.min.js"></script>
<!-- online javaScript CDN of bootstrap 4.0.0 -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
</head>

<body>
<div style="width: 50%; margin: 20px auto">

<form method="post" class="form-horizontal" id="contact-form"
data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
data-bv-feedbackicons-validating="glyphicon glyphicon-refresh">
<div class="input-group mb-3 size">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-user"></i></span>
</div>
<input type="text" class="form-control" placeholder="First Name" name="first_name" required
data-bv-notempty="true"
data-bv-notempty-message="The username is required and cannot be empty">
<div class="invalid-feedback">Please enter your First Name</div>
</div>

<div class="input-group mb-3 size">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-user"></i></span>
</div>
<input type="text" class="form-control" placeholder="Last Name" name="last_name" required
data-bv-notempty="true"
data-bv-notempty-message="The username is required and cannot be empty">
<div class="invalid-feedback">Please enter your Last Name</div>
</div>

<button type="submit" class="btn btn-lg btn-primary text-align-center btn-block"><i class="fas fa-paper-plane"></i> Send</button>

</form>
</div>
</body>

<!-- This script is in external .js file -->
<script>
$(document).ready(function() {
//alert("HEllo Nehal");
$('#registrationForm').bootstrapValidator();
});

</script>

关于jquery - 如何修复 php 文件中的 bootstrapValidator 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55445221/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com