我想在我的表单中使用bootstrapValidator,但我发现它不起作用。
下面是html代码。
<link href="css/bootstrap.min.css" rel="stylesheet" />
<link href="css/style.css" rel="stylesheet" />
<link href="css/bootstrapValidator.css" rel="stylesheet" />
<div class="col-sm-6 col-lg-6">
<form id="form_login" method="post" action="#">
<h2>Log In</h2>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="email" name="email" id="loginemail" class="form-control input-lg" placeholder="Email Address" tabindex="1">
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="password" class="form-control input-lg" id="loginpassword" maxlength="12" placeholder="Password" tabindex="2">
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-6"><input type="submit" value="Log In" class="btn btn-theme btn-block btn-lg" tabindex="3"></div>
<div class="col-xs-12 col-md-6">Don't have an account? <a href="signin.html" tabindex="3">Register</a></div>
</div>
</form>
</div>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery-3.1.0.js"></script>
<script src="js/bootstrapValidator.js"></script>
<script src="js/validations.js"></script>下面是jquery代码
$(document).ready(function() {
$('#form_login').bootstrapValidator({
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
loginemail: {
validators: {
notEmpty: {
message: 'The first name is required and cannot be empty'
}
}
},
loginpassword: {
validators: {
notEmpty: {
message: 'The last name is required and cannot be empty'
}
}
} /* <-- removed unneeded comma */
} /* <-- added closing brace */
});
});从早上开始,我试着找出问题所在,但我还没能找到它。任何人都可以建议或帮助我解决这个问题
发布于 2020-07-04 01:14:25
验证元素的“name”属性必须与插件初始值设定项中的“”field“”名称相同,将根据“”name“”属性验证插件。“”在bootstrapValidator的验证器字段中有id名称。虽然它是相当旧的,但如果有些人有问题,我可能会帮助你。
发布于 2021-07-02 02:34:16
您需要有一个输入类型submit才能使bootstrapValidator工作。
https://stackoverflow.com/questions/39425387
复制相似问题